vue开发使用vue-particles如何兼容IE11?

最近开发vue项目,项目有一个粒子特效使用vue-particles。项目用vue-cli构建,webpack打包完毕,丢到服务器,chrome访问完美,测试360和Edge也正常。
遗憾的是,在IE11显示一片空白。F12,第一次也没有发现错误,刷新后,报错:

SCRIPT: 缺少':'

网上搜了很多种方法,测试IE浏览器不支持新的ES6语法等情况,但import 'babel-polyfill'后仍然没有任何改观。
开始逐步排查,找到是vue-particles的问题,修改vue-particles/index.js后IE访问正常。
原vue-particles/index.js代码如下:

import particles from './vue-particles.vue'

const VueParticles = {

install (Vue, options) {
        Vue.component('vue-particles', particles)
    }

}

export default VueParticles

IE不支持install(){}这种写法,故修改如下:

import particles from './vue-particles.vue'

const VueParticles = {

    install: function (Vue, options) {
        Vue.component('vue-particles', particles)
    }

}

export default VueParticles

猜你喜欢

转载自www.cnblogs.com/jlfw/p/11931547.html