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
        }

猜你喜欢

转载自blog.csdn.net/geyaoisnice/article/details/124933530