在网上看到这么一个例子,用on去绑定,但是on不是jQuery的方法吗?在Vue中可以直接写on吗?为什么我用addEventListener会不支持此方法?
let that = this;
this.button1.on('click',function(e){
this.addClass('on'); //this指代所点的元素
that.doSomething(); //that指向类的this
})
在网上看到这么一个例子,用on去绑定,但是on不是jQuery的方法吗?在Vue中可以直接写on吗?为什么我用addEventListener会不支持此方法?
let that = this;
this.button1.on('click',function(e){
this.addClass('on'); //this指代所点的元素
that.doSomething(); //that指向类的this
})
10 回答11.2k 阅读
5 回答4.9k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.8k 阅读✓ 已解决
2 回答4.8k 阅读✓ 已解决
4 回答4.4k 阅读✓ 已解决
4 回答1.9k 阅读✓ 已解决
点击事件直接在html标签那里写@click=“”就行