Vue打包未将img中src的文件打包进去

时间:2024-03-04 17:08:19

源代码:

<img src="src/assets/images/fileImg/help.png"/> 

打包报错:

This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
error during build:
Error: [vite]: Rollup failed to resolve import "src/assets/images/fileImg/help.png" from "src/views/index/components/repData.vue".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`

解决:
src中的路径使用@/ 即可

<img src="@/assets/images/fileImg/help.png"/>