RouterLink在Vue Js中未正确显示

时间:2018-09-22 03:54:28

标签: vue.js vuejs2 vue-router element-ui

在Vue Js中使用routerLink时遇到问题。它仅显示localhost:8080 /#/ purchase-orders。因为我添加了params属性,所以它应该是localhost:8080 /#/ purchase-orders / 2。我该如何解决?

<el-table-column
                            fixed="right"
                            property="action"
                            label="Action"
                            width="120">
                            <template slot-scope="scope">
                                <router-link :to="{ path: '', params: { id: 2 }}">
                                    <el-button type="text" size="small">Detail</el-button>
                                </router-link>
                                <el-button type="text" size="small">Edit</el-button>
                            </template>
                        </el-table-column>

1 个答案:

答案 0 :(得分:2)

如果使用路径,则会忽略

参数。 您需要改用名称

它应该像这样:(假设 orders 是路线的名称)

<router-link :to="{ name: 'orders', params: { id: 2 }}">

或者,如果您想使用 path ,则必须提供完整路径。

https://router.vuejs.org/guide/essentials/navigation.html

  

注意:如果提供了路径,则忽略参数,如上面的示例所示,查询不是这种情况。相反,您需要提供路线名称或使用任何参数手动指定整个路径:

相关问题