父组件控制子组件的事件
通过在父组件里给子组件一个标识,ref='自定义名称,然后在父组件方法里通过this.$refs.自定义名称.事件名进行触发控制
代码如下
父组件里 <template> <view> <Item ref='aaa'></Item> </view> </template> <script> method:{ bbb(){ this.$refs.aaa.ccc(); } } </script>
子组件Item
<template> <view> </view> </template> <script> method:{ ccc(){ console.log('我是子组件') } } </script>