1,子组件
<template>
<h1>props传递参数</h1>
<p>{{title}}</p>
<ul>
<li v-for="item in nelist">{{item}}</li>
</ul>
</template>
<script>
export default{
name:"mycomponent",
props:{
title:{
type:String,
default:""
},
nelist:{
type:Array,
default:""
}
}
}
</script>
<style scoped>
h1{
color:red;
}
</style>
2,父组件
<template>
<MyComponent :title="title" :nelist="nelist"/>
</template>
<script>
import MyComponent from "./components/MyComponent.vue"
export default{
name:"app vue",
data(){
return{
title:"我是参数",
nelist:[1,2,3]
}
},
components:{
MyComponent
}
}
</script>
文章来自 96net.com.cn
标签:vue,title,default,参数,父传子,Props,MyComponent,export From: https://www.cnblogs.com/96net/p/17675113.html