绑定属性引号是否添加

2019-06-19  本文已影响0人  小透明进击战

v-bind:class 指令也可以与普通的class属性共存。当有如下模板

<div
  class="static"
  v-bind:class="{ active: isActive, 'text-danger': hasError }"
></div>

datad对象中的内容为

data: {
  isActive: true,
  hasError: false
}

结果渲染为

<div class="static active"></div>

绑定属性时,使用v-bind时,当key中含有js不支持的变量命名格式,如:-(中划线)和空格的时候,就需要给这些属性加引号''。

上一篇 下一篇

猜你喜欢

热点阅读