[英]Using Vue in Laravel
我是 Vue 的新手,但我想我會在最近的一個項目中試一試,我明白為什么喜歡它。 無論如何,一切都很順利,直到我切換到 IE,在那里什么都不起作用。
對於諸如Object doesn't support property or method 'assign'
我給了它一個谷歌,顯然 IE 不太支持 ES6,根據這個問題: Getting Error: Object does not 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
嗎?
你需要一個 polyfill: https : //babeljs.io/docs/en/babel-polyfill
將其作為條目 (app.js) 的第一行導入。
但是,我建議完全使用vue cli而不是 laravel mix。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.