全栈学习笔记

关注

underscore之uniqueId

全栈学习笔记

关注

阅读 45

2023-06-26


 

     uniqueId

 

   _.uniqueId([prefix])

 

  • 为需要的客户端模型或DOM元素生成一个全局唯一的id
  • 如果参数prefix指定了,id将附加给它

 


//从0开始
var idCounter = 0;

_.uniqueId = function(prefix){

      var id  = "" + (++idCounter);

      //判断是否有prefix
      return prefix ? prefix + id : id;
 
};


 

相关推荐

其生

go 生成UniqueId

其生 52 0 0

kmoon_b426

underscore的数组操作之difference

kmoon_b426 58 0 0

小月亮06

underscore2-15

小月亮06 66 0 0

NicoalsNC

Underscore.js

NicoalsNC 63 0 0

IT影子

关于underscore 在node中常用应用

IT影子 191 0 0

浮游图灵

【Python】如何正确使用下划线 underscore

浮游图灵 93 0 0

软件共享软件

node.js 什么是模板引擎?(具体介绍underscore)

软件共享软件 13 0 0

覃榜言

H5单页面架构:自定义路由 + requirejs + zepto + underscore

覃榜言 24 0 0

7dcac6528821

mybatis配置mybatis.configuration.map-underscore-to-camel-case=true

7dcac6528821 119 0 0

闲嫌咸贤

使用underscore模块的template功能实现对HTML的数据注入+template实现数据注入(后面更新)

闲嫌咸贤 88 0 0

精彩评论(0)

0 0 举报