Javascript Laravel 5.3和Vue 2
我正在一个新的Laravel 5.3应用程序中使用Vue 2,我不知道如何以Laravel格式绑定URL 我从数据库中提取了一些配置行,我只想在它们上面循环显示数据,然后显示一个按钮,将您带到编辑屏幕。Vue不支持在URL中简单插入配置行的ID,因为我正在使用以下命令循环行:Javascript Laravel 5.3和Vue 2,javascript,php,laravel,vue.js,Javascript,Php,Laravel,Vue.js,我正在一个新的Laravel 5.3应用程序中使用Vue 2,我不知道如何以Laravel格式绑定URL 我从数据库中提取了一些配置行,我只想在它们上面循环显示数据,然后显示一个按钮,将您带到编辑屏幕。Vue不支持在URL中简单插入配置行的ID,因为我正在使用以下命令循环行: <tr v-for="config in data"> <td> <a href="/configurations/{{ config.id }}/edit">{{ conf
<tr v-for="config in data">
<td>
<a href="/configurations/{{ config.id }}/edit">{{ config.name }}</a>
</td>
</tr>
我似乎无法获取要呈现的返回URL,它通常会抛出错误或抱怨我的var未定义
如何完成此(简单)任务?解决方案是忽略计算URL函数,只需执行以下操作:
<a v-bind:href="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
}
}
}