vite中使用img标签

<img class="icon-logo" :src="iconsUrl[imgName]" alt="" />

const icons = import.meta.glob('../../assets/img/print/*.png');
const iconsUrl = reactive<any>({});
Object.keys(icons).forEach((el) => {
icons[el]().then((res) => {
iconsUrl[el.replace(/\.\.\/\.\.\/assets\/img\/print\/(.*)\.png/, '$1')] =
res.default;
});
});
posted @ 2022-08-12 17:07  键盘敲飞  阅读(388)  评论(0编辑  收藏  举报