美文网首页
绑定属性引号是否添加

绑定属性引号是否添加

作者: 小透明进击战 | 来源:发表于2019-06-19 10:38 被阅读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不支持的变量命名格式,如:-(中划线)和空格的时候,就需要给这些属性加引号''。

    相关文章

      网友评论

          本文标题:绑定属性引号是否添加

          本文链接:https://www.haomeiwen.com/subject/kidhqctx.html