在路由器Vue中传递参数

时间:2020-03-01 11:25:21

标签: laravel vue.js components

我遇到了问题。我无法正常工作。

我有一个称为Projet的组件。在里面,我有这段代码:

我想要当我单击项目时将带我到另一个详细信息页面 但什么也没发生:

{path: '/detail/:id', component: detail}

这是我组件中的代码

        <tr v-for="projet in projets" :key="projet.id" >
           <router-link :to="{ name: 'detail', params: {id:  projet.id } }" style="text-decoration:none; color:black;">        <td>{{ projet.name }}</td></router-link>
                  <td>{{ projet.owner }}</td>
                  <td>{{ projet.durre }}</td>

                  <td>-------</td>
                  <td><i  data-toggle="modal" data-target="#description" class="fas fa-scroll" ></i></td>
                  <td>{{projet.budget}}</td>
                  <td>      <a href="#" @click="deleteProjet(projet.id)" ><i class="fas fa-trash-alt"></i></a>

2 个答案:

答案 0 :(得分:1)

我认为您错过了路由器名称。

尝试

{path: '/detail/:id', component: detail, name: 'detail'}

答案 1 :(得分:0)

尝试一下:


<router-link :to="'detail/' + projet.id" style="text-decoration:none; color:black;">     
相关问题