Skip to content

Home > sculp-js > stringFormat

stringFormat() function

字符串格式化

Signature:

typescript
export declare function stringFormat(string: string, ...args: Array<unknown>): string;

Parameters

Parameter

Type

Description

string

string

字符串模板,使用 %s 表示字符串,%d 表示数值,%o 表示对象,%% 表示百分号,参考 console.log

args

Array<unknown>

Returns:

string

{string}

Example

js
stringFormat("My name is %s.", "zhangsan")
// => "My name is zhangsan."

Released under the MIT License.