API Reference > @easyops-cn/brick-next-pipes > randomString
randomString() function
获得一个随机字符串
Others
Signature:
export declare function randomString(
length?: number,
characters?: string
): string;
Parameters
| Parameter | Type | Description |
|---|---|---|
| length | number | 随机字符串的长度,默认为 8。 |
| characters | string | 随机字符串包含哪些字符,默认为大小写字母及数字。例如指定"0123456789"则随机字符只会包含数字;指定"0123456789abcdef"则随机字符是个 16 进制数。 |
Returns:
string
随机字符串
Example
randomString();
// Returns "jUf92Zd0".
randomString(6);
// Returns "sUf0Zd".
randomString(6, "0123456789@");
// Returns "971@12".