如何解决属性内插法已删除。使用v-bind或冒号速记?Vue.JS 2

vue.js Vue.js

猪猪蛋蛋

2020-03-10

我的Vue组件是这样的:

<template>
    <div>
        <div class="panel-group" v-for="item in list">
            ...
            <div class="panel-body">
                <a role="button" data-toggle="collapse" href="#purchase-{{ item.id }}" class="pull-right" aria-expanded="false" aria-controls="collapseOne">
                    Show
                </a>
            </div>
            <div id="purchase-{{ item.id }}" class="table-responsive panel-collapse collapse" role="tabpanel">
            ...
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        ...
        computed: {
            list: function() {
                return this.$store.state.transaction.list
            },
            ...
        }
    }
</script>

执行时,存在如下错误:

Vue模板语法错误:

id =“ purchase-{{item.id}}”:属性内插已删除。请改用v-bind或冒号速记。

我该如何解决?

第489篇《如何解决属性内插法已删除。使用v-bind或冒号速记?Vue.JS 2》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

2个回答
梅十三 2020.03.10

只需使用

:src="`img/profile/${item.photo}`"
西门ItachiL 2020.03.10

使用v-bind或快捷方式语法“:”来绑定属性。例:

<input v-bind:placeholder="title">
<input :placeholder="title">

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android