#vue 父组件调用子组件方法出现this.$refs.c1.closeul is not a function 完美
html中组件代码块如下:
<dselect v-model="mobanValue" @clear='clearSelect($event)' :options='options3' @change="dselectFun($event)" @input='dselectFun($event)' ref="c1"></dselect>
ref="c1"是关键
在Vue.component注册的组件dselect的methods中有这个方法:
想在Vue中调用组件内的方法:
结果在调试时出现报错:
解决办法:
将this.$ refs.c1.closeul改成this.$refs.c1[0].closeul即可