gpt4 book ai didi

vue.js - @click 和 v-on 的区别 :click Vuejs

转载 作者:搜寻专家 更新时间:2023-10-30 22:07:14 25 4
gpt4 key购买 nike

问题应该足够清楚。

但我可以看到有人使用:

<button @click="function()">press</button>

有人使用:

<button v-on:click="function()">press</button>

但实际上两者之间有什么区别(如果存在的话)

最佳答案

两者没有区别,一个只是第二个的简写。

The v- prefix serves as a visual cue for identifying Vue-specificattributes in your templates. This is useful when you are using Vue.jsto apply dynamic behavior to some existing markup, but can feelverbose for some frequently used directives. At the same time, theneed for the v- prefix becomes less important when you are building anSPA where Vue.js manages every template.

<!-- full syntax -->
<a v-on:click="doSomething"></a>
<!-- shorthand -->
<a @click="doSomething"></a>

来源:official documentation .

关于vue.js - @click 和 v-on 的区别 :click Vuejs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45369553/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com