How can I solve quot;Interpolation inside attributes has been removed. Use v-bind or the colon shorthandquot;? Vue.js 2(如何解决“属性内的插值已被删除.使用 v-bind 或冒号简写?Vue.js 2)
问题描述
我的 Vue.js 组件是这样的:
<template>...<div 类=面板主体"><一个角色=按钮"数据切换=折叠";href=#purchase-{{ item.id }}"类=拉右";aria-expanded=假";aria-controls="collapseOne">展示</a></div>执行时出现如下错误:
<块引用>Vue 模板语法错误:
id="purchase-{{ item.id }}": 内插属性有被移除.请改用 v-bind 或冒号简写.
我该如何解决?
解决方案 在 v-bind
中使用 JavaScript 代码(或快捷方式:"):
:href="'#purchase-' + item.id"
和
:id="'purchase-' + item.id"
或者如果使用 ES6 或更高版本:p>
:id="`purchase-${item.id}`"
My Vue.js component is like this:
<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>
When executed, there exists an error like this:
Vue template syntax error:
id="purchase-{{ item.id }}": Interpolation inside attributes has
been removed. Use v-bind or the colon shorthand instead.
How can I solve it?
解决方案 Use JavaScript code inside v-bind
(or shortcut ":"):
:href="'#purchase-' + item.id"
and
:id="'purchase-' + item.id"
Or if using ES6 or later:
:id="`purchase-${item.id}`"
这篇关于如何解决“属性内的插值已被删除.使用 v-bind 或冒号简写"?Vue.js 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
织梦狗教程
本文标题为:如何解决“属性内的插值已被删除.使用 v-bind 或冒号简写"?Vue.js 2
基础教程推荐
猜你喜欢
-
在 contenteditable 中精确拖放
2022-01-01
-
Bootstrap 模态出现在背景下
2022-01-01
-
检查 HTML5 拖放文件类型
2022-01-01
-
原生拖动事件后如何获取 mouseup 事件?
2022-01-01
-
fetch 是否支持原生多文件上传?
2022-01-01
-
Fabric JS绘制具有活动形状的多边形
2022-01-01
-
Bokeh Div文本对齐
2022-01-01
-
如何添加到目前为止的天数?
2022-01-01
-
即使用户允许,Gmail 也会隐藏外部电子邮件图片
2022-01-01
-
npm start 错误与 create-react-app
2022-01-01