通过添加transform-object-assign
和array-includes
的插件,我一直在拼凑对IE11的支持,现在我使用for of
循环时出现了符号错误。不是一次一个地处理它们,我是否可以将babel polyfill工作到我的构建中并且将来证明它?
我已经阅读了几个相关问题,但仍然不清楚我如何将babel-polyfill融入下面的gulp构建中:
return gulp.src(input) // Grab the input files
.pipe($.babel({
presets: ['es2015'], // transform ES6 to ES5 with Babel
plugins: ['transform-object-assign','array-includes']
}))
.pipe($.concat(outputFile))
.pipe($.uglify({
compress: {
drop_debugger: true
}
}))
.pipe(gulp.dest(paths.output)) // Output file destination
.pipe($.connect.reload());
}
答案 0 :(得分:0)
修改强>
我注意到babel-polyfill和IE的问题,当我恢复到这个npm包" babel-polyfill":" 6.5.0"一切都开始正常工作
<强> /修改
您使用的是browserify吗?此外,您还需要var app = angular.module('app', []);
app.controller('demoController', ['$scope', function ($scope) {
$scope.input = [];
$scope.masters = [ {
"name": "Wittgenstein",
"thoughts": ["thought 1", "thought 2", "thought 3"]
}, {
"name": "King",
"thoughts": ["thought 1", "thought 2", "thought 3"]
}];
$scope.add = function(index) {
$scope.masters[index].thoughts.push($scope.input[index]);
$scope.input[index] = '';
};
$scope.remove = function(master, index) {
master.thoughts.splice(index, 1);
};
}]);
和插件babel-polyfill
继承了我与babel6的IE兼容性的gulp任务:
['transform-es2015-classes', { loose: true }]]