我正在使用 VueJS 2.0 和 Laravel 5.3。我有 Vue 数组数据(例如 items
)。现在我想使用 v-for
在表中呈现这些数据。在表格中,有一个按钮可以将页面重定向到项目详细信息页面。为此,我将静态 URL 写入 /
在标签的 href 中。然后我附加 {{item.id}}。但我收到此错误。
Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of , use
<div :id="val">
所以我不明白如何在<a href="">
中编写VueJS的数据绑定(bind)表达式。如果有人知道解决方案,将不胜感激。
这是我的代码。
my-items.blade.php
<div id="app">
....
<tr v-for="item in items">
<td>
<a href="{{url('/item')}}/@{{item.id}}">view</a>
</td>
</tr>
....
</div>
my-items.js
new Vue({
el: '#app',
data: {
items: [
{id: 1},
{id: 2},
{id: 3}
]
},
})
编辑
这是我在 AngularJS 和 Laravel 5.2 中所做的事情。我想要类似的。
<a href="{{url('/item')}}/@{{item.id}}">view</a>
最佳答案
应该像下面这样:
<tr v-for="item in items">
<td>
<a :href="'{{url('/item')}}/' + item.id" />
</td>
</tr>
关于laravel - 在<a>标签的href中编写VueJS数据绑定(bind)表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41234800/