<img src="../assets/imgs/0.jpg" alt="">
<img src="https://cdn.pixabay.com/photo/2023/04/01/21/11/tunnel-7893124_640.jpg" alt=""> <img src="https://glpla.github.io/utils/wallpaper/w0.jpg" alt="">
let src = '../assets/imgs/0.jpg'
<img :src="src" alt="">
let src = '/imgs/10.jpg'
<img :src="src" alt=""/>
import src from '../imgs/10.jpg'
<img :src="src" alt=""/>
<img :src="getImageUrl(src)" alt=""/>
let src = '../imgs/10.jpg' const getImageUrl = (img) => { return new URL(img, import.meta.url).href }
let src = '../imgs/10.jpg' const getImageUrl = (img) => { return new URL(`../imgs/${img}`, import.meta.url).href }
<div>public</div> <img src="/imgs/banner.png" alt=""/> <div>assets</div> <img src="./assets/imgs/banner.png" alt=""/> <div>src -> imgs</div> <img src="./imgs/banner.png" alt=""/>
<img src="../imgs/10.jpg" alt=""/>
本质上是从根路径引用,所以也可以从 / 开始,引入任意地方的资源;但是打包的时候,会出现问题,因为打包后没有 src 目录
<img v-for="img in imgs" :key="img.id" :src="`/src/assets/${img.src}`"/>