<lmbtnB ref="lmb" >按钮1</lmbtnB>
<lmbtnB ref="lmb" >按钮2</lmbtnB>
<button @click="aaa"></button>
aaa(){
this.$refs.lmb.reset()
}
reset()这个为组件的内部方法
当调用 this.$refs.lmb.reset() 时,只有按钮2可以生效
有没有方法可以让只要是ref的参数相同的,都可以触发成功reset(),也就是让按钮1和按钮2都生效
7***@qq.com (作者)
[Vue warn]: Error in v-on handler: "TypeError: Cannot read property 'reset' of undefined"
found in
---> <LmbtnA> at components/lmbtnA/lmbtnA.vue
<Root>
[system] TypeError: Cannot read property 'reset' of undefined
出现两个报错
2023-02-07 15:47
7***@qq.com (作者)
console.log(this.$refs.lmb[0]) 执行这句结果:undefined
2023-02-07 15:48