Vue.JS параметры соединения с маршрутизатором из запроса AJAX - PullRequest
0 голосов
/ 17 ноября 2018

Я пытаюсь создать роутер-ссылку с vue, и когда я пытаюсь передать параметр, который я получаю из запроса AJAX, используя axios.Но в тот момент, когда я загружаю страницу, я получаю уведомление, что параметр отсутствует, и он отображается как неопределенный.Как мне обойти это?

<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

1 Ответ

0 голосов
/ 17 ноября 2018

Уже решено. Использовали не то свойство. Нужно быть uuid вместо id ..

...