Vuejs2 Can';无法通过URL更改加载组件
我有一个加载组件并进行验证的路径Vuejs2 Can';无法通过URL更改加载组件,vuejs2,vue-component,vue-router,Vuejs2,Vue Component,Vue Router,我有一个加载组件并进行验证的路径 { path: "/sso/:id/:atex/:entityId/:ip", name: "SSO", component: () => import("./views/account/sso"), meta: { beforeResolve(to, routeFrom, next) { if (localStorage.getItem('userDetails') || local
{
path: "/sso/:id/:atex/:entityId/:ip",
name: "SSO",
component: () => import("./views/account/sso"),
meta: {
beforeResolve(to, routeFrom, next) {
if (localStorage.getItem('userDetails') || localStorage.getItem('user')) {
next({ path: "/" + to.params.entityId })
}
next();
}
},
}
在组件中,如果用户有效
this.$router.replace("/" + this.$route.params.entityId);
下面是/
{
path: "/:entityId?",
name: "Companies",
meta: {
authRequired: true,
beforeResolve(routeTo, routeFrom, next) {
next();
},
},
component: () => import("./views/dashboards/CompaniesGrid"),
},
在组件中,我搜索包含entityId值的表格单元格,然后单击它以查看/dashboard
var len = document.querySelectorAll('td').length;
for (var i=0; i < len; i++){
if ( document.querySelectorAll('td')[i].innerText == (this.$route.params.entityId).toUpperCase()){
document.querySelectorAll('td')[i].setAttribute('id', this.$route.params.entityId);
document.getElementById(this.$route.params.entityId).click();
}
}
如何解决这个问题以及为什么会发生这种情况?
您要么从不解决导航承诺,要么您的组件在渲染过程中有一个错误。在控制台中没有错误是VUE DeVoots中显示的导航吗?Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/dashboard".