Vue课程42-事件绑定-处理函数的简写方式

 处理函数可以去除function进行书写

 add(n) {
          // 在 methods 处理函数中,this 就是 new 出来的 vm 实例对象
          // console.log(vm === this)
          console.log(vm)
          // vm.count += 1
          this.count += n
        },
        sub() {
          // console.log('触发了 sub 处理函数')
          this.count -= 1
        }

posted @ 2022-07-05 18:42  前端导师歌谣  阅读(32)  评论(0)    收藏  举报