我试图用vue创建一个路由器链接,当我尝试传递参数时,我使用axios从AJAX请求中接收到了参数。但是在我加载页面的那一刻,我注意到该参数丢失了,并且显示为未定义。我该如何解决?
<tr v-for="obj in fetched">
<td v-text="obj.isocode"></td>
<td v-text="obj.name"></td>
<td><router-link :to="{ name: 'str-route-masterdata-country-edit', params: { id: obj.id }}">Edit</router-link></td>
</tr>
export default {
name: "starlight-masterdata-country-index",
components: {StarlightTable},
data: function() {
return {fetched: []}
},
mounted: function () {
let vm = this;
Axios.get('http://127.0.0.1:5000/masterdata/countries',
{crossDomain: true}
)
.then(function (response) {
// handle success
vm.fetched = response.data;
})
.catch(function (error) {
// handle error
//TODO: Add flash message to screen to show the api request failed
window.console.log(error);
});
},
}
错误消息:
vue-router.esm.js?8c4f:16 [vue-router] missing param for named route "str-route-masterdata-country-edit": Expected "id" to be defined
答案 0 :(得分:0)
已经解决。使用了错误的属性。需要是uuid而不是id。