### v-bind:class #### 属性 - 我们可以传给 `v-bind:class` 一个对象,以动态地切换 class ```js
data: { isActive: true, hasError: false } ``` #### 对象 ```js //绑定的数据对象不必内联定义在模板里: data: { classObject: { active: true, 'text-danger': false } } data: { isActive: true, error: null }, computed: { classObject: function () { return { active: this.isActive && !this.error, 'text-danger': this.error && this.error.type === 'fatal' } } } ``` #### 数组 ```js data: { activeClass: 'active', errorClass: 'text-danger' } ``` #### 用在组件上 组件中信息不会被覆盖而是追加 ### 绑定内联样式 v-bind:style - CSS property 名可以用驼峰式 (camelCase) 或短横线分隔 (kebab-case,记得用引号括起来) 来命名 ```html ``` ```js data: { activeColor: 'red', fontSize: 30 } data: { styleObject: { color: 'red', fontSize: '13px' } } ```