国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Schritte zum Installieren von jQuery in Nuxt.js
P粉755863750
P粉755863750 2023-11-06 16:41:50
0
1
887

Obwohl ich versucht habe, jQuery zu meinem Projekt hinzuzufügen, ist eine Fehlermeldung aufgetreten, die besagt, dass es nicht definiert ist.

plugins: [
    { src: '~/plugins/js/svgSprite.js', mode: 'client' },
    { src: '~/plugins/vendor/jquery/jquery.min.js', mode: 'client' },
    { src: '~/plugins/vendor/bootstrap/js/bootstrap.bundle.min.js', mode: 'client' },
    { src: '~/plugins/vendor/bootstrap-select/js/bootstrap-select.min.js', mode: 'client' }, <-- 給我報錯
    { src: '~/plugins/vendor/magnific-popup/jquery.magnific-popup.min.js', mode: 'client' },
    { src: '~/plugins/vendor/smooth-scroll/smooth-scroll.polyfills.min.js', mode: 'client' },
    { src: '~/plugins/vendor/object-fit-images/ofi.min.js', mode: 'client' },
    { src: '~/plugins/js/theme.js', mode: 'client' }
  ],

Warum passiert das? Offensichtlich habe ich jQuery vor Bootstrap-Select deklariert.

P粉755863750
P粉755863750

Antworte allen(1)
P粉277824378

我不建議在Nuxt項目中添加jQuery。


但是如果你真的想要添加,可以按照以下步驟進行:

  • 使用yarn add jquery安裝它
  • 將以下內(nèi)容添加到你的nuxt.config.js文件中
import webpack from 'webpack'

export default {
  // ...
  build: {
    plugins: [
      new webpack.ProvidePlugin({
        $: 'jquery',
        jQuery: 'jquery',
        'window.jQuery': 'jquery'
      })
    ]
  },
}
  • 確保你的.eslintrc.js文件中有以下內(nèi)容
module.exports = {
  // ...
  env: {
    // ...
    commonjs: true,
    jquery: true
  },
}

然后,你可以在method或類似的地方這樣使用它

$("h2").addClass("tasty-class")
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage