【发布时间】:2020-07-20 19:44:36
【问题描述】:
我使用类似于这种形式的动态路由:
router.js
...
{
path: "/init/clients/moral-person/:company",
name: "moralPerson",
component: () => import('../MoralPerson.vue'),
meta: {
auth: true,
breadcrumb: [
{ text: "Init", disabled: false, name: "init" },
{ text: "Clients", disabled: true, name: "" },
{ text: "Moral Person", disabled: false, name: "crudMoralPerson"},
{ text: "Company", disabled: true, name: "", icon: "fas fa-dollar-sign"},
]
}
}
...
注意:面包屑的部分是为其他组件渲染的。
当我做 router.push 是这样的:
一些文件
...
this.$router.push({
name: "moralPerson",
params: { company: this.nameCompany }
});
...
最后看起来像这样:
我尝试使用 this.router.params,在本例中为 :company 并位于我标记的蓝色部分或此处:
router.js
...
// in this line
{ text: :company, disabled: true, name: "", icon: "fas fa-dollar-sign"},
...
我的问题是,如何访问此参数并在我需要的这部分中配置?
编辑
我尝试:
...
{ text: this.$route.params.empresa, disabled: true, name: "", icon: "fas fa-dollar-sign"},
...
总是发给我:
【问题讨论】:
标签: vue.js vue-router