Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically obtain route data and configure the relevant single page. Clicking one of the routing addresses will report an error. #517

Closed
WangLucy opened this issue Oct 6, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@WangLucy
Copy link

WangLucy commented Oct 6, 2020

Version

3.0.0

Reproduction link

http://xujiawangzhi.com

Steps to reproduce

App.vue:

Configured dynamic routing :

const formatterRoutes = (menu, appPrefix, appName) => {
const accessedRoutes = []
menu.map(item => {
let defaultOpt = {}
let componentItem = () => import(@/views${item.path}/index.vue)
defaultOpt = {
meta: {
title: item.menuName,
icon: item.icon,
appName,
appPrefix
},
path: item.path,
name: item.name,
...
}
if (
item.children &&
Object.prototype.toString.call(item.children === '[object Array]' && item.children.length)
) {
accessedRoutes.push({
...defaultOpt,
children: formatterRoutes(item.children,appPrefix,appName)
})
} else {
accessedRoutes.push({...defaultOpt})
}
})
return accessedRoutes
}

What is expected?

Error is reported in "vue-router": "^4.0.0-beta.13", but it can be run in "vue-router": "3.0.6",

What is actually happening?

in "vue-router": "^4.0.0-beta.13":
Uncaught (in promise) TypeError: Cannot use 'in' operator to search for 'then' in undefined;
No match found for location with path "/system/department"

@posva posva transferred this issue from vuejs/core Oct 6, 2020
@posva
Copy link
Member

posva commented Oct 6, 2020

@WangLucy I transferred this to vue-router-next. From the error I can tell you're passing an undefined value as one of the component properties in one of your routes.
The warning shouldn't fail though so I will adapt it

@posva posva added the enhancement New feature or request label Oct 6, 2020
@posva posva closed this as completed in 5985b65 Oct 6, 2020
@WangLucy
Copy link
Author

WangLucy commented Oct 9, 2020

hi~

In static routing, "matched" has a value, but in dynamic routing, "matched" is empty. I found that "createrouter()" is only executed at initialization time, and does not execute this method again after logging in to get dynamic routing data【 router.addRoute () this method will not call "createrouter()" again 】, so it will issue a warning like "no match found for location with path" / xxx / xxx "every time you click the menu. Can you give me some suggestions?!

@WangLucy
Copy link
Author

WangLucy commented Oct 9, 2020

Sorry, the above URL is false, some of the links provided by the URL I can't visit, so I wrote the fake URL, please don't mind!

@ZHT131
Copy link

ZHT131 commented Jul 26, 2021

@WangLucy Hello, have you solved this problem? I will also report a warning if I add a route dynamically, but the redirection is okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants