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>

 

相关文章:

  • 2021-10-22
  • 2021-09-04
  • 2021-10-30
  • 2022-02-15
  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
  • 2021-10-02
猜你喜欢
  • 2022-12-23
  • 2022-01-09
  • 2021-11-02
  • 2022-12-23
  • 2021-11-08
  • 2021-11-28
相关资源
相似解决方案