Nuxt3 使用问题总结

932 阅读1分钟

最近在使用 Nuxt3 重构 Blog,开发过程中遇到不少问题,记录一下,遇到问题会持续更新这篇文章

public静态资源

按照原来 Nuxt2 的方式,在 assets 的目录进行图片存放,引用图片资源时发现 404 了,查阅了下文档

Nuxt won't serve files in the assets/ directory at a static URL like /assets/my-file.png. If you need a static URL, use the public/ directory.

Nuxt3 不再为 assets 目录下提供静态 URL, 那么引用图片资源 404 要放到 public 目录下

<!-- public/imgs/logo.png -->
<img src="/imgs/logo.png" alt="logo" />