【发布时间】:2019-04-13 01:12:42
【问题描述】:
我是 Vue 的新手,但我想我会在最近的一个项目中尝试一下,我知道它为什么喜欢它。无论如何,一切都很顺利,直到我切换到 IE,什么都没有。
出现Object doesn't support property or method 'assign' 之类的错误,我给了它一个谷歌,显然 IE 不能很好地支持 ES6,根据这个问题:Getting Error: Object doesn't support property or method 'assign'
所以,我听说过 Babel,它看起来可以胜任这项工作,因为它能够从 ES6 转换。在此之后,我尝试将 Babel 集成到我的 Laravel 项目中。
我更新了我的webpack.min.js 如下:
let mix = require('laravel-mix');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
mix.js('resources/assets/js/app.js', 'public/js')
.webpackConfig({
module: {
rules: [{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
}]
}
})
.sass('resources/assets/sass/app.scss', 'public/css');
if (!mix.inProduction()) {
mix.webpackConfig({
devtool: 'source-map'
})
.sourceMaps();
} else if (mix.inProduction()) {
mix.version();
}
mix.browserSync({
proxy: '127.0.0.1:8000'
});
env包参考:https://babeljs.io/docs/en/babel-preset-env
但是,这似乎并没有解决我的问题。
我应该改用mix.babel 吗?
【问题讨论】:
-
通常你会使用
npm run dev来编译开发。我想这就是 laravel mix 的帮助,因为它包含了将资产代码编译为兼容代码的工具。你正确使用 Laravel mix 了吗? -
我运行了 dev 并没有什么不同
-
你用的是什么版本的IE?
-
IE11是我用的版本
标签: javascript php laravel vue.js webpack