VUE学习笔记十三:父组件调用子组件方法
vue父组件:
<doone-table :option="contactOption" :data="cantactData" ref="tbl"></doone-table> <span @click="test">点击</span>
export default {
methods:{
test (){
this.$refs.tbl.$emit('click') ; //方法1
this.$refs.tbl.testFun(); //方法2
},
}
}vue子组件:
exprot default {
methods:{
testFun(){
alert(456)
}
},
mounted () {
this.$on('click',function(){
alert(123);
})
}
}
文章
总共 0 条评论