Skip to content

uniqueId

js
_.uniqueId([prefix=''])

生成唯一 ID。如果给出了 prefix,则将 ID 附加到它。

¥Generates a unique ID. If prefix is given, the ID is appended to it.

新增于

¥Since

0.1.0

参数

¥Arguments

  1. [prefix=''] (字符串):要作为 ID 前缀的值。

    ¥[prefix=''] (string): The value to prefix the ID with.

返回

¥Returns

(字符串):返回唯一 ID。

¥(string): Returns the unique ID.

示例

¥Example

js
_.uniqueId('contact_');
// => 'contact_104'

_.uniqueId();
// => '105'

Lodash v4.17 中文网 - 粤ICP备13048890号