Cannot redefine property: $router -- 完善解决方案 #1766
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
vue使用cdn资源,页面报错
Cannot redefine property: $router
,从qiankun faq找到解决方案。然后这个方案并不是那么完美,因为有些三方包会有类似判断:
'Vue' in window
,比如vuedraggable,部分源码如下这样会导致if条件为true,从而执行window.Vue 而这时window.Vue已经不存在导致新错误发生。
解决方案:
window.Vue2 = window.Vue;
delete window.Vue;