定义:props能够决定组件与组件之间的数据交互
Prop传递参数没有类型限制:
String,Number,Boolean,Array,object,Function
注意事项:数组和对象必须使用函数进行返回
例子:
引入组件代码:
<MyComponent :title="title" :age="20" />
组件代码:
<p>{{title}}</p>
export default{
name:"MyComponent",
//用prop接受传过来的title的数据
prop:{
title:{
type:String,
default:""
}
age:{
type:Number,
default:0
}
}
}