1:配置别名(vite.config.js)
import { resolve } from "path";
resolve:{
alias: {
// 配置目录别名
"@": resolve("./src"),
views: resolve("./src/views"),
utils: resolve("./src/utils"),
},
}
2:vite引入图片(循环显示的,不是写死的)
图片转换方法,因为import引入的是Promise对象
bannerList.map(async (item, index) => {
const path = await item.src;
console.log(item.src)
bannerList[index] = { ...item, src: path?.default };
});