文档 优化静态资源路径使用说明,补充完整的使用示例

This commit is contained in:
yuantao
2026-01-20 10:39:19 +08:00
parent dc272d289f
commit 7b9ce380b2

View File

@@ -196,11 +196,19 @@ npm run upload:weapp
* **资源路径**: 使用全局混入的 `ASSETSURL` 变量
* **使用方式**:
```javascript
```html
// 在template中
<image src="`${ASSETSURL}image.png`"/>
```
```html
// 在CSS中
background-image: url($ASSETSURL + 'image.png')
```
```javascript
// 在JavaScript中
const ASSETSURL = import.meta.env.VITE_ASSETSURL
const imageUrl = `${ASSETSURL}image.png`
```