如何解决iview在安卓4.4.4的webview中的兼容性

项目脚手架:vue-cli 3.x,用了 vue + vue-router + iview
iview为按需引入,用了:Row, Col, Button, Carousel, CarouselItem, Icon

问题描述

问题:在高版本浏览器访问正常,在安卓4.4.4 webview(内核为Chrome 33)中访问,页面空白,调试报错为:

Uncaught SyntaxError: Use of const in strict mode. app.js:4328
./node_modules/iview/src/utils/assist.js app.js:4328
__webpack_require__ app.js:768
fn app.js:131
./node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js?!./node_modules/iview/src/components/carousel/carousel.vue?vue&type=script&lang=js& app.js:1001
__webpack_require__ app.js:768
fn app.js:131
./node_modules/iview/src/components/carousel/carousel.vue?vue&type=script&lang=js& app.js:4103
__webpack_require__ app.js:768
fn app.js:131
./node_modules/iview/src/components/carousel/carousel.vue app.js:4091
__webpack_require__ app.js:768
fn app.js:131
./node_modules/iview/src/components/carousel/index.js app.js:4127
__webpack_require__ app.js:768
fn app.js:131
./src/plugins/iview.js app.js:5328
__webpack_require__ app.js:768
fn app.js:131
./src/main.js app.js:5316
__webpack_require__ app.js:768
fn app.js:131
(anonymous function) app.js:5412
__webpack_require__ app.js:768
(anonymous function) app.js:904
(anonymous function)

尝试解决

看报错可能是ES6+语法问题,于是尝试通过添加polyfill,按vue-cli 3.x文档polyfill相关指南,使用了其第3种方式:

babel.config.js:
  presets: [
    ['@vue/app', {
      useBuiltIns: 'entry'
    }]
  ]

main.js:
import '@babel/polyfill'

.browserslistrc:
chrome >= 33
android >= 4.4

测试问题没有解决

相关链接

求指导,求建议

阅读 5.3k
1 个回答

把iview按需引入改为全局引入,测试问题解决了...
不知道为什么按需引入就会报错,全局引入就正常,非常地无语,弄了一整个下午

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题