首页 > 其他 > 详细

underscore的使用

时间:2019-07-03 23:09:34      阅读:108      评论:0      收藏:0      [点我收藏+]

1、链接

  npm underscore:https://www.npmjs.com/package/underscore

  官网:https://underscorejs.org/

 

2、npm安装:npm install underscore

3、简单使用

var _ = require("underscore");

var array = _.map([1, 2, 3], (x) => x * x);
console.log(array); // [ 1, 4, 9 ]

var array2 = _.map(["A", "B", "C"], (x) => x.toLowerCase());
console.log(array2); //[ ‘a‘, ‘b‘, ‘c‘ ]

// template():声明模板数据
var fn = _.template("<h2>hello, I am <%= name %>!</h2>"); // template()函数的返回值类型为函数
var html = fn({name: ‘hanmeimei‘});
console.log(html); // <h2>hello, I am hanmeimei!</h2>

 

underscore的使用

原文:https://www.cnblogs.com/xy-ouyang/p/11129443.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!