You've already forked template-MP
文档 优化静态资源路径使用说明,补充完整的使用示例
This commit is contained in:
12
IFLOW.md
12
IFLOW.md
@@ -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`
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user