模板正常绑定方式传值即可
props接收后可直接使用,参考watch函数,method内使用同样是 this.flag
props: {
flag: String
},
watch: {
flag() {
console.log(this.flag)
}
},
this.$emit('rander', true)
rander() {
this.flagRander = false
this.$nextTick(function () {
this.flagRander = true
})
},
子组件中的true
在本例中无用,如需使用,写法如下:
rander(data) {
...
}
[Prop 验证https://cn.vuejs.org/v2/guide/components-props.html#Prop-%E9%AA%8C%E8%AF%81
[vm.$emithttps://cn.vuejs.org/v2/api/#vm-emit