2
我在新的Laravel 5.3应用程序中玩Vue 2,我不确定如何绑定laravel格式的URL。Laravel 5.3 and Vue 2
我有一些从数据库中拉出的配置行,我想简单地遍历它们显示数据,然后显示一个按钮,将您带到编辑屏幕。 Vue公司不支持只需在URL插值的配置行的ID,因为我使用遍历行:
<tr v-for="config in data">
<td>
<a href="/configurations/{{ config.id }}/edit">{{ config.name }}</a>
</td>
</tr>
的Vue的文档说绑定到另一个这样的功能:
<a v-bind:href="url">
然后我有这样定义的URL方法:
export default {
mounted() {
console.log('Component ready.')
},
data: function() {
return {
data: [config data array]
}
},
computed: {
url: function() {
console.dir(this); // the whole component, not the row
console.dir(this.id); // undefined
console.dir(this.config); // undefined
return "/configurations/" + this.config.id + "/edit" // throws error
}
}
}
我似乎无法获取返回的URL来渲染,它通常要么抛出一个错误或抱怨说我的变种是不确定的。
如何完成这项(简单)任务?