Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

255
Visualizações
How to convert Swiper.js into ES5

I use babel to convert it but the swiper is not working and it shows this error in console.

enter image description here

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.

enter image description here

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/"))
 }

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda