IE和Safari上的Vuejs Laravel空白页面

问题描述 投票:1回答:0

我的webapp在Chrome和Firefox上可以正常运行,但在IE8-11和Safari上不能正常运行。 我使用Laravel 5.6和最新版本的VueJS (带有laravelmix webpack)。

我以为const变量类型不能被IE和Safari读取(我认为有必要在es5中编译es6)。

我尝试在app.js文件中导入babel,但也尝试了很多库,但没有结果:

- npm install es6-promise
- npm i --save @babel/polyfill
- npm i babel-polyfill
- npm i bufferutil --save -optional
- .babelrc file in root
- npm i --save-dev babel-preset-stage-2
- npm i --save-dev babel-cli babel-preset-es2015
- npm i --save-dev babel-preset-env
- npm i joi-browser
- npm i --save-dev babel-preset-es2015-node6
- npm i --save-dev babel-preset-stage-0

还是laravelmix文件(webpack.mix.js)应该能够使用正确的配置?

我也试过这个:
-在webpack.mix.js文件中

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');

 mix.webpackConfig({
   node: {
     fs: 'empty'
   }
 });
// mix.webpackConfig({

//   module: {
//     rules: [
//       {
//         test: /\.js?$/,
//         use: {
//           loader: 'babel-loader',
//           options: {
//             presets: ['es2015'] // default == env
//           }
//         }
//       }
//     ]
//   }
// });

// OR

// mix.webpackConfig({
//         module: {
//             rules: [{
//                 test: /\.js?$/,
//                 exclude: /(bower_components)/,
//                 use: [{
//                     loader: 'babel-loader',
//                     options: mix.config.babel()
//                 }]
//             }]
//         }

//     });

.babelrc文件:

 {
     "presets": ["es2015"]
 }

{
  "presets": [
    [
      "env",
      {
        "modules": false,
        "browsers": ["IE >= 9", "> 1%"]
      }
    ],
    "stage-2"
  ],
  "plugins": ["transform-runtime"],
  "comments": false
}

如果您有解决方案或遇到类似情况,请不要犹豫。 我已经在网上和自己进行搜索,但是没有任何效果。 如果您需要更多信息,请在评论中告诉我。

编辑:错误MSG:SyntaxError:意外的关键字'const'。 在严格模式下不支持const声明。 (苹果浏览器)

laravel vue.js ecmascript-6 babel ecmascript-5
© www.soinside.com 2019 - 2024. All rights reserved.