res 调用子组件的方法

console.log(this.$refs.testCom); VueComponent {_uid: 3, _isVue: true, $options: {…}, _renderProxy: Proxy, _self: VueComponent, …} console.log(this.$refs.dynamic0); [VueComponent]

1、单独一个的组件this.$refs.name 选择出来的是一个对象,可以直接调用其方法如 this.$refs.testCom.say();
2、遍历的组件this.$refs.name 选择出来的是一个数组,需要这样调用方法this.$refs.dynamic0[0].say();【虽然ref的时候给的名称是唯一的了,但还是会生成一个数组】

原文地址:https://www.cnblogs.com/hyx626/p/11231598.html