v-on事件处理中函数名有无括号的区别

知乎回答:https://www.zhihu.com/question/55753541

 

个人理解:

 

不加括号当解析器,会传入一个默认参数,这个默认参数就是触发时间$event

 

加了括号当js代码执行

 

show: function(e) {
    console.log(e);
}

// <button type="button" @click="show">CLICK</button>     => click事件触发对象

// <button type="button" @click="show()">CLICK</button>     => undefinded

 

posted @ 2021-01-06 15:33  铽楉QAQ  阅读(147)  评论(0)    收藏  举报