I use babel to convert it but the swiper is not working and it shows this error in console.
I go to the line where this error happen and add console.log().
if (params.el && $(params.el).length > 1) {
var swipers = [];
console.log($(params.el))
$(params.el).each(function (containerEl) {
var newParams = extend({}, params, {
el: containerEl
});
swipers.push(new Swiper(newParams));
});
return swipers;
} // Swiper Instance
There's no problem getting these elements but somehow $(...).each just doesn't work.
What can i do to fix this?
Or is there something wrong when converting?
My .babel is simple, as below
{
"presets": ["es2015"]
}
I use gulp-babel to convert it.
In package.json:
"dependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-preset-env": "^1.7.0",
"gulp": "^4.0.2",
"gulp-babel": "^7.0.1",
"url-search-params-polyfill": "^8.1.1"
},
"devDependencies": {
"babel-preset-es2015": "^6.24.1"
},
And in gulpfile.js:
function to_es5() {
gulp
.src("./src/js/*.js")
.pipe(
babel({
presets: ["es2015"], })
)
.pipe(gulp.dest("./src/js-es5/"))
}