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

[Bug]: Getting router is undefined when the page reloads after user logged #436

Closed
phpmathan opened this issue May 14, 2024 · 3 comments
Closed

Comments

@phpmathan
Copy link

Software Version

v1.1.0

Operating Environment

Ubuntu

Operating Architecture

AMD64

Reproduce Steps

After the user logged in, if the page reloads and uses static auth routes, then we get router is undefined error the page is not rendering because of no auth routes.

What is the expected result?

Replace the following import in src/store/modules/tab/index.ts

import { useRouter } from 'vue-router'; to import { router } from '@/router';

What is the actual result?

After replacing the router from 'vue-router' to '@/router' it is working fine, hence the behavior is same.

Logging (Optional)

No response

Additional Description (Optional)

No response

@honghuangdc
Copy link
Member

could you give me the more detail reproduction

@phpmathan
Copy link
Author

I've created the modular structure for easy code management and reuse the modules, and I initialize the modules before the setupRouter in main.ts, during the module initialization I prepare the static routes which internally call tabStore.initHomeTab() which triggered the error router is undefined.

20240514200107

20240514200255

Changing import { useRouter } from 'vue-router'; to import { router } from '@/router'; in src/store/modules/tab/index.ts solves my problem. I created this ticket for users like me who customize may see such issues, and these notes may help them.

@honghuangdc
Copy link
Member

ok, thanks, I'll do as you suggest.

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

No branches or pull requests

2 participants