【问题标题】:- selected="{{ associationId==association.value }}": Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead- selected="{{ associationId==association.value }}":属性内的插值已被删除。改用 v-bind 或冒号简写
【发布时间】:2017-07-22 20:16:28
【问题描述】:

我迁移到了 VueJS 2,现在,Chrome 告诉我:

  • selected="{{ associationId==association.value }}":属性内的插值已被删除。请改用 v-bind 或冒号简写。例如,不要使用<div id="{{ val }}">,而是使用<div :id="val">
  • <select v-model="associationSelected">:使用 v-model 时,<option> 上的内联选定属性将被忽略。改为在组件的数据选项中声明初始值。
  • 无效的表达式::selected="item.list=={{ federationId==federation.value }}"

代码如下:

<div class="form-group">
    <label for="association_id" class="text-bold">Asociacion</label>

    <select name="association_id" v-model="associationSelected" id="association_id"
            class="form-control" v-on:change="getClubs(associationSelected)">
    <option v-for="association in associations" v-bind:value="association.value"
            selected="{{ associationId==association.value }}">
        {{ association.text }}
    </option>
    </select>
</div>  

消息非常明确,但是当我尝试使用 :select 时,我得到了

无效的表达式::selected="item.list=={{ federationId==federation.value }}"

我应该改变什么?

【问题讨论】:

    标签: javascript vue.js


    【解决方案1】:

    我认为v-bind:selected="associationId == association.value" 应该可以工作

    【讨论】:

    • 它给了我:属性或方法“associationId”未在实例上定义,但在渲染期间引用。确保在 data 选项中声明反应数据属性。 (在 中找到)
    • 在我看来,我在最后,让 associationId = "";
    • @JuliatzindelToro 您需要将associationId 添加到您的数据对象中
    • 但是我是通过php获取这些数据的,那么我应该如何声明呢?关联标识:关联标识???
    • @JuliatzindelToro 很酷,很高兴听到这个消息!
    猜你喜欢
    • 2018-04-22
    • 2018-05-19
    • 2019-01-30
    • 2020-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多