如何将外部JavaScript和swiper.js文件添加到Nuxt 3(nuxt.config.ts)?

huangapple go评论114阅读模式
英文:

How to add external JavaScript and swiper.js files to Nuxt 3 (nuxt.config.ts)?

问题

尝试过在nuxt.config.ts中添加外部JavaScript文件,但是Nuxt 3没有加载该文件。CSS文件正常工作,只有脚本文件无法正常工作。进行了大量研究但未找到正确答案,其他人也提出了这个问题,请帮助我,非常感谢。版本 Nuxt 3: 3.4.1
nuxt.config.ts 文件: 图片链接

英文:

I tried to add an external javascript file to nuxt.config.ts but nuxt 3 didn't load the file.But the CSS files work correctly, Only the script files don't work properly, I did a lot of research but I didn't get the right answer, this question is also asked by other people, please help me very much, thank you very much. version Nuxt 3 : 3.4.1
nuxt.config.ts file:[enter image description here](https://i.stack.imgur.com/R5ACH.jpg)

I sent two photos, please see.

答案1

得分: 1

你应该将 Swiper 注册为你的 Nuxt 3 项目的插件。请参阅 https://nuxt.com/docs/guide/directory-structure/plugins

英文:

You should register swiper as a plugin for your Nuxt 3 project. See https://nuxt.com/docs/guide/directory-structure/plugins

huangapple
  • 本文由 发表于 2023年4月17日 22:27:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76036219.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定