Vue Router - отсутствует параметр для именованного маршрута eror - PullRequest
0 голосов
/ 14 января 2020

Мой идентификатор успешно переносится на мой URL, но я не уверен, почему я получаю эту ошибку. Я попробовал метод, в котором я добавил параметры по умолчанию к своему path: '*', но безрезультатно.

enter image description here

маршрутов. js

{
  path: '/objective/employee/:id',
  name: 'employee-objective',
  component: () => import('@/views/EmployeeObjective'),
  meta: { requiresAuth: true }
},

Компонент

<template>
  <v-container>
    <p class="display-2 text-center">DASHBOARD</p>
    <p class="overline text-center">Current route is still under construction</p>

    <template v-for="employee in employees" >
      <v-row :key="employee.id">
        <v-col ><router-link :to="{ name: 'employee-objective', params: { id: employee.id }}">{{ employee.first_name }}</router-link></v-col>
      </v-row>
    </template>
    </v-container>
</template>

<script>
  export default {
    data: ()=> ({
      employees: []
    }),

    created () {
      this.employeeList ()
    },

    methods: {
      employeeList () {
        axios
        .get('/api/employees')
        .then(response => this.employees = response.data)
        .catch(error => console.log(error))
      }
    }
  }
</script>

1 Ответ

0 голосов
/ 14 января 2020

Скорее всего, в ваших employee данных отсутствует поле id.

Проверьте следующие примеры:

...