1.首先在data里面去定义
data () {
const showList = [0, 1, 2, 3, 4, 5]
return {
showList
}
}
2.

   switchBox (boxIndex) {
        let index = this.showList.indexOf(boxIndex)
        if (index >= 0) {
          this.showList.splice(index, 1)
        } else {
          this.showList.push(boxIndex)
        }
      },

这种写法真的很棒的,同事写的

posted on 2019-06-18 16:24  周小姐你好  阅读(215)  评论(0编辑  收藏  举报