uniapp端静态资源存放说明

为减少小程序打包体积,uniapp端静态资源存放在后端项目static.mini目录下

企业微信截图_17765104503592(1).png

1.使用说明

  • uniapp已定义通用静态资源拼接函数:staticResource 项目内统一的静态资源路径生成方法,适用于图片、音频等静态文件地址拼接,避免在页面里手写完整 URL。
  • staticResource(path: string, type = "images"): stringpath:资源相对路径,例:"common/safety.png"
    type:资源目录类型,默认值为 "images",可按实际目录传入如 "audio"

2.使用实例

<template>
  <image :src="staticResource('common/safety.png')" />
</template>
<script setup lang="ts">
import { staticResource } from "@/utils";
</script>
uniapp端静态资源存放说明
请输入搜索内容
大纲
为减少小程序打包体积,uniapp端静态资源存放在后端项目static.mini目录下
1.使用说明
2.使用实例