vue3使用import引入图片资源

2022-03-09  本文已影响0人  燕自浩
1. 引入

<script>标签内使用import引入 例如

import zhIcon from "@/static/zh.png";
import enIcon from "@/static/en.png";
2. 使用setupreturn抛出到template 例如
import { reactive, toRefs } from "vue";
setup() {
  const state = reactive({});
  return {
    ...toRefs(state),
    zhIcon,
    enIcon 
  }
}
3. 在template内部使用 例如(uni内使用image)
<image :src="zhIcon"  />

一点一滴的积累让自己变得强大 奥力给

上一篇下一篇

猜你喜欢

热点阅读