【发布时间】:2021-11-28 01:41:39
【问题描述】:
我已将 Vite 的别名 "@" 配置为 "./src"。
直接使用别名为<img>.src即可:
<!-- this is ok -->
<img src="@/assets/icon-1.svg">
但是将src 作为道具传递是行不通的:
<!-- ComponentA -->
<template>
<img :src="imgSrc">
</template>
<!-- Parent Component: alias not resolved as expected; imgSrcWithAlias is "@/assets/icon-1.svg" -->
<component-a :img-src="imgSrcWithAlias" />
传递props时使用文件路径别名有什么解决办法吗?
【问题讨论】: