Skip to main content
Version: v2

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​

TypeDescription
stringThe base path, which will be spliced before the resource file path

AssetsPathFunc​

TypeDescription
(path: Path, isRtl?: IsRtl) => ResultPathResource file path constructor

Path​

TypeDescription
stringResource file path

IsRtl​

TypeDescription
booleanWhether to splice the rtl path

ResultPath​

TypeDescription
stringFinal 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