简体   繁体   中英

In Vue 3 how do I reference a local resource when using a UI Framework (without "@")?

I am accustomed to using the "@" character in Vue 3 so the location will still be referenced after Vite build, as in the following example:

<img src="@/assets/picture.jpg" />

With custom components from UI Frameworks, I can't figure out how to reference my images anymore, The "@" no longer works. since it is rendering out the custom component.

Element Plus example:

<el-image src="@/assets/picture.jpg" />

I tried using various permutations without the "@" sign. I couldn't readily find the answer in Vue 3 docs or docs for Element Plus or Chakra UI frameworks, and it is a hard question to search for here.

Okay, I found out how this can work, but it's hardly a solution

<script setup>
import imageUrl from "@/assets/picture.jpg";
</script>

<template>
  <div>
    <el-image :src="imageUrl" />
  </div>
</template>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM