账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    为什么 Vue 的 webpack 模板不使用 polyfill 也能在 IE 浏览器上使用 assign 等 ES6+ 方法
    79
    0
    1. 为什么 Vue 的 Webpack 模板不使用 polyfill 也能在 IE 浏览器上使用 Object.assign 等 ES6+ 方法。而且在模板的package.json和相关配置没有看到babel-polyfill
    2. babel-loader 不能根据我的代码中ES6使用情况自动添加相关的polyfill吗?感觉使用我的配置是根据browserlist 添加的polyfill
    3. 当我自己使用 Webpack4 的时候,如果需要使 IE 浏览器上能正确使用 ES6+ 方法。需要在入口文件添加一行import 'babel-polyfill'

    附上我的webpack配置:

    'use strict';
    const path = require('path');
    module.exports = {
      mode: 'development',
      entry: {
        index: path.join(__dirname, './index.js'),
      },
      output: {
        filename: '[name].bundle.js',
      },
      devtool: 'cheap-module-eval-source-map',
      devServer: {
        contentBase: path.resolve(__dirname, './'),
        port: 8000,
      },
      module: {
        rules: [
          {
            test: /\.js$/,
            exclude: /node_modules/,
            use: {
              loader: 'babel-loader',
              options: {
                cacheDirectory: true,
                presets: [[ 'env', {
                  useBuiltIns: true,
                }]],
                plugins: [ 'transform-runtime' ],
              },
            },
          },
        ],
      },
    };
    
    
    3
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部