当前位置: 首页 > Web前端 > HTML5

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

时间:2023-04-05 15:50:54 HTML5

最近开发了一个vue项目,该项目使用vue-particles实现了粒子效果。项目用vue-cli搭建,webpack打包,扔到服务器,chrome访问完美,测试360和Edge也正常。不幸的是,在IE11中它显示为空白。F12,第一次没有发现错误。刷新后报错:SCRIPT:missing':'。在网上搜索了很多方法,测试过IE浏览器不支持新的ES6语法等等,但是导入'babel-polyfill'后还是没有任何变化。开始一步步排查,发现vue-particles的问题。修改vue-particles/index.js后,IE访问正常。原vue-particles/index.js代码如下:importparticlesfrom'./vue-particles.vue'constVueParticles={install(Vue,options){Vue.component('vue-particles',particles)}}exportdefaultVueParticlesIE不支持install(){},所以修改如下:importparticlesfrom'./vue-particles.vue'constVueParticles={install:function(Vue,options){Vue.component('vue-particles',particles)}}导出默认VueParticles