Skip to content

KBE3D / KBCore / utils / template

函数: template()

template(str: string, data: Record<string, any>, toEmpty?: boolean): string

根据数据和格式化字符串模板,返回字符串

参数

str

string

格式化字符串模版,属性字段为大括号,如

data

Record<string, any>

数据对象

toEmpty?

boolean = false

是否将模板中未匹配项转为空值

返回

string

返回字符串

示例

ts
 const str = KBCore.utils..template("<div>名称:{{name}}</div>", { name:"zh", date:"1949-10-1"} );
 // str结果为 : "<div>名称:zh</div>"

KBE3D @3.0.0 Copyright © 2024-present KBE3D