解决方法一
根据官网的提示,我找到了最简单的方法,就是在将asset 前面加上src。
解决方法二
关于第二个方法,官网说:"实际上,Vite 并不需要在开发阶段处理这些代码!在生产构建时,Vite 才会进行必要的转换保证 URL 在打包和资源哈希后仍指向正确的地址。"
动+静
<img :src="`/src/assets/images/survey/${v.code}.png`" >图片文件位置

纯静(轮播图)
<el-carousel type="card" height="133px" arrow="never" :autoplay="false">
 <el-carousel-item v-for="item in bannerInfo" :key="item">
    <img :src="item" style="width: 100%;border-radius: 5px"/>
  </el-carousel-item>
</el-carousel>
const bannerInfo = ref([
  new URL('@/assets/images/safeguard_banner.png', import.meta.url).href,
  new URL('@/assets/images/safeguard_banner2.png', import.meta.url).href,
  new URL('@/assets/images/safeguard_banner3.png', import.meta.url).href,
])
<img :src="" alt="getImageUrl(name)" />
function getImageUrl(name) {
    return new URL(`../assets/blogPhotos/${name}.jpg`, import.meta.url).href;
}