• underscore的使用


    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>
  • 相关阅读:
    滑动条使用
    jquery日历练习
    JQuery 教程
    JS获取各种宽度、高度的简单介绍
    如何获取元素位置
    DOM练习
    DOM
    函数
    假期练习
    Uva 253 Cube painting
  • 原文地址:https://www.cnblogs.com/xy-ouyang/p/11129443.html
Copyright © 2020-2023  润新知