javascript - - 选择 ="{{ associationId==association.value }}": Interpolation inside attributes has been removed. 使用 v-bind 或冒号简写

标签 javascript vue.js

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

  • selected="{{ associationId==association.value }}": Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of <div id="{{ val }}">, use <div :id="val">.
  • <select v-model="associationSelected">: inline selected attributes on <option> will be ignored when using v-model. Declare initial values in the component's data option instead.
  • invalid expression: :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 时,我明白

invalid expression: :selected="item.list=={{ federationId==federation.value }}"

我应该改变什么?

最佳答案

我认为v-bind:selected="associationId == Association.value"应该有效

关于javascript - - 选择 ="{{ associationId==association.value }}": Interpolation inside attributes has been removed. 使用 v-bind 或冒号简写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42566702/

相关文章:

javascript - 具有加载更多功能的时间轴

javascript - 如何在 html 文件中包含 markdown (.md) 文件

javascript - Angularjs:无法将类添加到 ID

javascript - Vuejs : fade out-in transition not working

javascript - 单击 Vue.Js 中对话框上的按钮后,从方法中打开 vue 组件

javascript - Vue.js 模态对话框不显示值

VueJS 组件模板中的 Django Form

javascript - 如何将 json 结果导入 PHP

javascript - 根据数字检查字符串是一种好的风格吗?

json - Vue-if 条件不起作用。 if-Else block 似乎被跳过