引入
ts
import { stringFormat } from 't-comm';
// 不支持 tree-shaking 的项目
import { stringFormat} from 't-comm/lib/string-format/index';
// 只支持 ESM 的项目
import { stringFormat} from 't-comm/es/string-format/index';
stringFormat(string, args)
描述:
String format template
- Inspired: https://github.com/Matt-Esch/string-template/index.js
参数:
参数名 | 类型 | 描述 |
---|---|---|
string | string | 字符串 |
args | any | 填充选项 |
示例
ts
stringFormat('{{likes}} people have liked this', {
likes: 123,
});