assets
Start from API_LEVEL
2.0. Please refer to API_LEVEL.
Used to handle resource file paths, splice basePath. and can pass in parameters for rtl path conversion of images, for RTL adaptation of Mini Program.
Type
function assets(basePath: BasePath): AssetsPathFunc
Parameters
BasePath
| Type | Description |
|---|---|
string | The base path, which will be spliced before the resource file path |
AssetsPathFunc
| Type | Description |
|---|---|
(path: Path, isRtl?: IsRtl) => ResultPath | Resource file path constructor |
Path
| Type | Description |
|---|---|
string | Resource file path |
IsRtl
| Type | Description |
|---|---|
boolean | Whether to splice the rtl path |
ResultPath
| Type | Description |
|---|---|
string | Final file path |
Example
import { assets } from '@zos/utils'
const imagePath = 'zeppos-logo.png'
const assetsPathFunc = assets('img')
console.log(assetsPathFunc(imagePath)) // img/zeppos-logo.png
console.log(assetsPathFunc(imagePath, true)) // img/zeppos-logo@rtl.png