Skip to content

引入

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

参数

参数名类型描述
stringstring

字符串

argsany

填充选项

示例

ts
stringFormat('{{likes}} people have liked this', {
  likes: 123,
});