Home > Web Front-end > JS Tutorial > Reasons and solutions for not using splicing in vue $refs

Reasons and solutions for not using splicing in vue $refs

不言
Release: 2018-09-17 14:12:19
Original
4452 people have browsed it

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

Copy after login
Copy after login
  •     
  • handleClearInterval(id) {
        _.each(this.$refs,(item,key)=>{
            if(key != 'audio'+index){
                console.log(this.$refs);
                console.log(this.$refs.audio[key])
            }
        })
    },
    Copy after login
    will report an error if you write it this way

    Reasons and solutions for not using splicing in vue $refs

    Change the way of writing, remove audio

    and change it to console.log(this.$refs[key])
    This still doesn’t work

    Reasons and solutions for not using splicing in vue $refs

    This is the official description

    Reasons and solutions for not using splicing in vue $refs

    Change to the following form

    Copy after login
    Copy after login
  •     
  • 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()
        }
      })
    },
    Copy after login

    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!

    Related labels:
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template