This article brings you the reasons and solutions for not using splicing in vue $refs. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
It is best not to use splicing in ref
handleClearInterval(id) { _.each(this.$refs,(item,key)=>{ if(key != 'audio'+index){ console.log(this.$refs); console.log(this.$refs.audio[key]) } }) },
Change the way of writing, remove audio
and change it to console.log(this.$refs[key])
This still doesn’t work
This is the official description
Change to the following form
handleClearInterval(id) { const audioList = this.filterListByType(this.info.instHomeworkContents,3) _.each(audioList,(item,key)=>{ if(item.id != id) { console.log(this.$refs) console.log(this.$refs.audio[key]); this.$refs.audio[key].clearInterval() } }) },
This way you can get the dom you want. Here I get it, loop out the sub-component, and then call the sub-component clearInterval() method.
The above is the detailed content of Reasons and solutions for not using splicing in vue $refs. For more information, please follow other related articles on the PHP Chinese website!