class和style绑定
- 属性绑定添加字符串类名html
<div :class="className"></div>
- 类名绑定时会在原有的基础上进行添加html
<div :class="className" class="item"></div>
- 数组形式添加类名html
<div :class="classList"></div>
jsclassList: ['a', 'b', 'c', 'd'],
- 对象形式添加类名 可以使用布尔值决定类名是否应该被添加html
<div :class="classObj"></div>
jsclassObj: { a: true, b: false, c: true },
- 样式添加 对象形式 在原有的基础上进行添加html
<div :style="styleObj" style="border: 10px solid black"></div>
jsstyleObj: { // 属性式样式属性的名称 值式样式属性的值 backgroundColor: 'red', width: '100px', height: '100px' },
- 样式添加 数组形式html
<div :style="styleList"></div>
jsstyleList: [ // 数组嵌套对象 { backgroundColor: 'blue' }, { width: '200px' }, { height: '200px' } ]