我用杯和通天成績單ES6到ES5屬性或方法「匹配」。這裏是我的代碼:對象不支持在邊緣
gulpfile.babel.js
import gulp from 'gulp';
import babel from 'gulp-babel';
gulp.src([appDir + 'js/**/*.js', '!' + appDir + 'js/{vendors,vendors/**}'])
.pipe(babel({
presets: ['es2015'],
plugins: ['transform-runtime']
}))
.pipe(gulp.dest(devDir + 'js'));
的package.json
"devDependencies": {
"babel-core": "*",
"babel-plugin-transform-runtime": "*",
"babel-preset-es2015": "*",
"gulp": "*",
"gulp-babel": "*",
}
.babelrc
{
"presets": [
"es2015"
],
"plugins": ["transform-runtime"]
}
Ë除了IE11和Edge之外,每件瀏覽器都可以正常工作。
IE11有錯誤:
'Symbol' is undefined
邊緣有錯誤:
Object doesn't support property or method 'matches'
我希望加入這個插件"plugins": ["transform-es2015-typeof-symbol"]
到.babelrc文件將解決 '符號' 是不確定的問題,但不是!
我是否缺少一些特殊的設置或轉換插件的babel?
你已經在你的依賴列表中有'babel-plugin-transform-runtime',但是你沒有在Babel的配置中啓用它。把兩個問題放在一個問題上也不是一個好主意。您使用'matches'的問題與Babel或Gulp或ES6完全無關。 – loganfsmyth
我有更新的代碼,但我現在有新的錯誤:的ReferenceError:要求沒有定義 – quarky
有了還有你的構建過程,沒有什麼會處理'import'和'export'正常。如果你在帶有模塊導入/導出的瀏覽器中加載,你會想使用Webpack。 – loganfsmyth