国庆节10月1日
--


使用v-bind(简写:)动态绑定HTML标签的属性和样式
v-bind指令用于动态绑定HTML标签的属性值,如href、src、style、class等。它可以将Vue实例中的数据绑定到HTML元素的属性上。
1<img v-bind:src="item.image" width="30px">1<img :src="item.image" width="30px">1<!-- 绑定class -->2<div :class="{ active: isActive, 'text-danger': hasError }"></div>3
4<!-- 绑定style -->5<div :style="{ color: activeColor, fontSize: fontSize + 'px' }"></div>1<a :href="url" :title="title" :target="target">链接</a>数据源要求:
v-bind绑定的数据必须在data()中定义data()中定义的数据计算而来简写形式:
:属性名="属性值"是v-bind:属性名="属性值"的简写class和style绑定:
属性值类型:
性能考虑:
如果你喜欢,那么欢迎来到我的世界!
了解更多暂未播放



"所有的相遇都是久别重逢。"—— 未知


