vue中v-on和v-bind的区别

v-bind指令用于设置HTML属性:v-bind:href 缩写为 :href

<!-- 完整语法 -->
<a v-bind:href="url">123</a>

<!-- 缩写 -->
<a :href="url">123</a>

v-on 指令用于绑定HTML事件 :v-on:click 缩写为 @click

<!-- 完整语法 -->
<a v-on:click="doSomething">123</a>

<!-- 缩写 -->
<a @click="doSomething">123</a>

最好不要用@,因为asp.net mvc页面识别@ 不太好

<a v-on:click="doSomething">aa</a>

猜你喜欢

转载自www.cnblogs.com/apebro/p/12601111.html
今日推荐