vue组件构成:
prop
最好使用对象方式 props
:{
msg
:{
type
:[Number
],
defalut
:2,
validator (value
):{
return true
}
}
}
evetsolt
组件通信
props、eventBus、ref、
p
a
r
e
n
t
/
parent/
parent/children、$emit $on
provide/inject成对出现 用法:允许一个祖先组件向子组件传入一个依赖 用法:(A组件为父 B为子)
export defult
{
provide
:{
name
:"我来自A组件"
}
}
export default{
inject
:["name"],
mouted
:{
console
.log(this.name
)
}
}
**** 这种传值不存在响应式、如果传入的数据是响应式的、则也是响应式
用处:登陆用的账户名字存储