Navigation

    云、贵、川、渝IT人的圈子
    • Register
    • Login
    • Search
    • 主页
    • 问答
    • 话题
    • 热门
    • 圈子
    • 招聘
    • 活动
    • 项目

    import node_modules 里面的包,打包出来以后不兼容ie11 怎么办

    技术答疑
    2
    2
    22
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jiaokunhong29 last edited by

      import tools from '@/tools'
      

      这个包,在常规浏览器上都是ok的,到了ie11 跑不起来,是库的代码不兼容ie11吗?

      1 Reply Last reply Reply Quote 0
      • 水灵
        水灵 last edited by 水灵

        ie11 不兼容的问题,有这几个

        node_modules 里面的包有es6/es7的语法,默认webpack是不会把它转成 es5的语法的,这种情况在ie11 上就会出现问题了

        vue-cli 的解决方案,在 vue.config.js 中增加如下配置

        module.exports = {
           // @/tools 为你实际引入的那个插件库的名称
           transpileDependencies: ['@/tools'],
        }
        

        另外一种解决方案,在项目中引入 babel-polyfill

        yarn add babel-polyfill 
        

        在项目的入口文件,main.js 中直接import即可

        import 'babel-polyfill '
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        J
        社
        8
        玻
        U
        A
        大
        A
        黑
        低
        天
        白
        快
        爱
        白
        美
        此
        荒
        为
        哭
        柳
        无

        社群
        昆明网页设计交流吧
        友情链接
        • Funtask
        • Funtask 社区
        • SUWIS
        • 云南北大青鸟
        ©2019-2020 滇ICP备20006698号