最近开发vue项目,项目有一个粒子特效使用vue-particles。项目用vue-cli构建,webpack打包完毕,丢到服务器,chrome访问完美,测试360和Edge也正常。
遗憾的是,在IE11显示一片空白。F12,第一次也没有发现错误,刷新后,报错:vue
SCRIPT: 缺乏':'
网上搜了不少种方法,测试IE浏览器不支持新的ES6语法等状况,但import 'babel-polyfill'后仍然没有任何改观。
开始逐步排查,找到是vue-particles的问题,修改vue-particles/index.js后IE访问正常。
原vue-particles/index.js代码以下:webpack
import particles from './vue-particles.vue' const VueParticles = { install (Vue, options) { Vue.component('vue-particles', particles) } } export default VueParticles
IE不支持install(){}这种写法,故修改以下:web
import particles from './vue-particles.vue' const VueParticles = { install: function (Vue, options) { Vue.component('vue-particles', particles) } } export default VueParticles