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

Cannot redefine property: $router -- 完善解决方案 #1766

Merged
merged 6 commits into from
Oct 15, 2021

Conversation

humorHan
Copy link
Contributor

@humorHan humorHan commented Oct 14, 2021

vue使用cdn资源,页面报错 Cannot redefine property: $router,从qiankun faq找到解决方案。

然后这个方案并不是那么完美,因为有些三方包会有类似判断: 'Vue' in window,比如vuedraggable,部分源码如下
image
这样会导致if条件为true,从而执行window.Vue 而这时window.Vue已经不存在导致新错误发生。

解决方案:
window.Vue2 = window.Vue;
delete window.Vue;

@humorHan humorHan changed the title Feat/compatible Cannot redefine property: $router -- 完善解决方案 Oct 14, 2021
@kuitos kuitos merged commit e90ca04 into umijs:master Oct 15, 2021
@gongshun
Copy link
Collaborator

gongshun commented Nov 9, 2021

@humorHan 英文版的文档没有修正

@humorHan
Copy link
Contributor Author

@humorHan 英文版的文档没有修正

抱歉抱歉,已经新提PR,望check~
最近业务略忙,刚看到...

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

Successfully merging this pull request may close these issues.

3 participants