vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.76k stars 6.33k forks source link

多页面应用在开发态中polyfill只打进了一个页面的js中,而其它页面没有polyfill (multipage app polyfill missing) #2999

Closed WinfredWang closed 5 years ago

WinfredWang commented 5 years ago

Version

3.1.1

Reproduction link

https://github.com/WinfredWang/vue-cli3-multipage-demo

Node and OS info

Node 8.12.0/npm 6.4.1

Steps to reproduce

1、clone https://github.com/WinfredWang/vue-cli3-multipage-demo

2、npm install

2、npm run serve

3、Open IE url:
http://localhost:8080/p1.html
http://localhost:8080/p2.html

4、click About link

What is expected?

p1 and p2 are all running normally

What is actually happening?

p.html1 or p2.html occur Promise undefined

两个页面p1.html (p1.js)和p2.html(p2.js),打包时promise polyfill 只打到了p1页面的p.js中,而p2页面的p2.js是没有这个垫片的,导致在IE11下报错。这种现象只在开发态出现,生产环境由于公共vendor被抽取到独立的js中了,所以不会有这种问题。

WinfredWang commented 5 years ago

I use dynamic import comonent , only occur in development mode.

https://github.com/WinfredWang/vue-cli3-multipage-demo/blob/master/src/p1/router.js#L20

When click About link in p1.html, it is wrong because of promise polyfill not included.

image

But in p2.html, it is OK.

image

troy351 commented 5 years ago

Vue的多页面是指在router里面配置的多页面,本质还是一个页面,只是切换了路由。 而你这个更像是两个独立的页面,应该不是那么用的吧

ghostcode commented 5 years ago

@troy351 可以这样用。但是说的polyfill什么意思,没看懂。

WinfredWang commented 5 years ago

@ghostcode 有两个页面p1.html (p1.js)和p2.html(p2.js),打包时promise垫片只打到了p1页面的p.js中,而p2页面的p2.js是没有这个垫片的,导致在IE11下报错。

dousybox commented 5 years ago

你可以参考这里的配置项来手动添加promise的polyfill。

这个问题其实是webpack本身的异步加载组件没有自带promise的polyfill导致的,需要你手动导入。

网上搜到的这篇文章讲的很清楚了。

希望对你有帮助。

haoqunjiang commented 5 years ago

Can't reproduce. Please try the latest release and see if the problem still occurs.

haoqunjiang commented 5 years ago

Closing due to inactivity for more than 1 week. Please open a new issue with a reference to this one if you can follow up with more information.