underscore.js 模板怎么分配数据

posts - 50,&
comments - 1,&
trackbacks - 0
随笔分类 - underscore.js
摘要: Returnstrueif thevalueis present in thelist, using===to test equality. UsesindexOfinternally, iflistis an Array.检测值是否在列表中出现过,如果出现返回true1 _.include([1, 2, 3], 3);2 =& true源码:1 _.include = _.contains = function(obj, target) {2 var found =3 if (obj == null)4 if (native...
himanhimao 阅读(312) |
摘要: A convenient version of what is perhaps the most common use-case formap: extracting a list of property values.很方便的为你提供一个获取列表值的方法1 var stooges = [{name : 'moe', age : 40}, {name : 'larry', age : 50}, {name : 'curly', age : 60}];2 _.pluck(stooges, 'name');3 =& [&quot
himanhimao 阅读(193) |
摘要: Returnstrueif any of the values in thelistpass theiteratortruth test. Short-circuits and stops traversing the list if a true element is found. Delegates to the native methodsome, if present.如果列表中有一个真正的实体值出现,那么将返回true,别名some1 _.any([null, 0, 'yes', false]);2 =& true源码: var any = _.some = _
himanhimao 阅读(130) |
摘要: Return the number of values in thelist.返回元素列表的长度1 _.size({one : 1, two : 2, three : 3});2 =& 3源码:1 _.size = function(obj) {2 return _.isArray(obj) ? obj.length : _.keys(obj).3 };
himanhimao 阅读(55) |
摘要: Produces a new array of values by mapping each value inlistthrough a transformation function (iterator). If the nativemapmethod exists, it will be used instead. Iflistis a JavaScript object,iterator's arguments will be(value, key, list).所有的javascript对象元素都将经过回调函数作用1 _.map([1, 2, 3], function(num)
himanhimao 阅读(309) |
摘要: Iterates over alistof elements, yielding each in turn to aniteratorfunction. Theiteratoris bound to thecontextobject, if one is passed. Each invocation ofiteratoris called with three arguments:(element, index, list). Iflistis a JavaScript object,iterator's arguments will be(value, key, list). De
himanhimao 阅读(868) |
摘要: Returnstrueifvariableisundefined.如果变量没有被定义1 _.isUndefined(window.missingVariable);2 =& true源码:1 _.isUndefined = function(obj) {2 return obj === void 0;3 };
himanhimao 阅读(99) |
摘要: Returnstrueif the value ofobjectisnull返回true,如果值是null对象1 _.isNull(null);2 =& true3 _.isNull(undefined);4 =& false源码:1 _.isNull = function(obj) {2 return obj ===3 };
himanhimao 阅读(83) |
摘要: ReturnstrueifobjectisNaN.Note: this is not the same as the nativeisNaNfunction, which will also return true if the variable isundefined.返回true如果对象是NaN, 原生函数isNaN.undefined类型也将返回true。这里将返回false1 _.isNaN(NaN);2 =& true3 isNaN(undefined);4 =& true5 _.isNaN(undefined);6 =& false源码: _.isNaN = fu
himanhimao 阅读(49) |
摘要: Returnstrueifobjectis a RegExp.返回true,如果是一个正则表达式1 _.isRegExp(/moe/);2 =& true源码:1 _.isRegExp = function(obj) {2 return toString.call(obj) == '[object RegExp]';3 };
himanhimao 阅读(63) |
摘要: Returnstrueifobjectis a Date.如果对象是一个日期类型1 _.isDate(new Date());2 =& true源码:1 _.isDate = function(obj) {2 return toString.call(obj) == '[object Date]';3 };
himanhimao 阅读(96) |
摘要: Returnstrueifobjectis eithertrueorfalse返回true,如果对象是bool类型1 _.isBoolean(null);2 =& false源码:1 _.isBoolean = function(obj) {2 return obj === true || obj === false || toString.call(obj) == '[object Boolean]';3 };
himanhimao 阅读(77) |
摘要: Returnstrueifobjectis a finite Number.返回true如果对象是一个有限的数目1 _.isFinite(-101);2 =& true3 4 _.isFinite(-Infinity);5 =& false源码:1 _.isFinite = function(obj) {2 return _.isNumber(obj) && isFinite(obj);3 };
himanhimao 阅读(46) |
摘要: Returnstrueifobjectis a Number (includingNaN).返回true,如果是数字类型,包括NAN1 _.isNumber = function(obj) {2 return toString.call(obj) == '[object Number]';3 };源码:1 _.isNumber = function(obj) {2 return toString.call(obj) == '[object Number]';3 };
himanhimao 阅读(169) |
摘要: Returnstrueifobjectis a String返回true,如果是字符串1 _.isString(&moe&);2 =& true源码1 _.isString = function(obj) {2 return toString.call(obj) == '[object String]';3 };
himanhimao 阅读(157) |
摘要: Returnstrueifobjectis a Function返回true.如果是一个方法1 _.isFunction(alert);2 =& true源码:1 _.isFunction = function(obj) {2 return toString.call(obj) == '[object Function]';3 };
himanhimao 阅读(70) |
摘要: Returnstrueifobjectis an Arguments object返回true,如果是arguments对象1 (function(){ return _.isArguments(arguments); })(1, 2, 3);2 =& true3 _.isArguments([1,2,3]);4 =& false源码:1 _.isArguments = function(obj) {2 return toString.call(obj) == '[object Arguments]';3 };4 if (!_.isArguments(argumen
himanhimao 阅读(40) |
摘要: Returnstrueifvalueis an Object.返回true,如果值是一个对象1 _.isObject({});2 =& true3 _.isObject(1);4 =& false源码:1 _.isObject = function(obj) {2 return obj === Object(obj);3 };
himanhimao 阅读(131) |
摘要: Returnstrueifobjectis an Array.返回true。如果对象是一个数组.1 (function(){ return _.isArray(arguments); })();2 =& false3 _.isArray([1,2,3]);4 =& true源码:1 _.isArray = nativeIsArray || function(obj) {2 return toString.call(obj) == '[object Array]';3 };
himanhimao 阅读(56) |
摘要: Returnstrueifobjectis a DOM element.返回true如果对象是DOM元素1 .isElement(jQuery('body')[0]);2 =& true源码:1 _.isElement = function(obj) {2 return !!(obj && obj.nodeType == 1);3 };
himanhimao 阅读(100) |
摘要: Returnstrueifobjectcontains no values.用于检测一个对象是否是空的1 _.isEmpty([1, 2, 3]);2 =& false3 _.isEmpty({});4 =& true源码:1 _.isEmpty = function(obj) {2 if (obj == null)3 if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;4 for (var key in obj) if (_.has(obj, key)) retur...
himanhimao 阅读(504) |
摘要: Performs an optimized deep comparison between the two objects, to determine if they should be considered equal.用于比较两个对象的值是否相当,而不是内存引用位置.1 var moe = {name : 'moe', luckyNumbers : [13, 27, 34]};2 var clone = {name : 'moe', luckyNumbers : [13, 27, 34]};3 moe ==4 =& false5 _.is
himanhimao 阅读(143) |
摘要: Does the object contain the given key? Identical toobject.hasOwnProperty(key), but uses a safe reference to thehasOwnPropertyfunction, in case it's been功能等同于object.hasOwnProperty(key),用于检测对象是否存在该属性.1 _.has({a: 1, b: 2, c: 3}, &b&);2 =& true源码:1 _.has = function(obj, key) {2 return h
himanhimao 阅读(43) |
摘要: Invokesinterceptorwith theobject, and then returnsobject. The primary purpose of this method is to &tap into& a method chain, in order to perform operations on intermediate results within the chain对象的拦截器,用于在对象方法链中,调试对象1 _.chain([1,2,3,200])2 .filter(function(num) { return num % 2 == 0; })3
himanhimao 阅读(59) |
摘要: Create a shallow-copied clone of theobject. Any nested objects or arrays will be copied by reference, not duplicated.创建对象的浅拷贝克隆.如果是值类型,则拷贝值;如果是引用类型,则拷贝引用地址。1 _.clone({name : 'moe'});2 =& {name : 'moe'};源码:1 _.clone = function(obj) {2 if (!_.isObject(obj))3 return _.isA
himanhimao 阅读(220) |
摘要: Fill in missing properties inobjectwith default values from thedefaultsobjects, and return theobject. As soon as the property is filled, further defaults will have no effect.将默认属性和值填充给对象。再次填充将没有效果1 var iceCream = {flavor : &chocolate&};2 _.defaults(iceCream, {flavor : &vanilla&,
himanhimao 阅读(145) |
摘要: Return a copy of theobject, filtered to only have values for the whitelistedkeys(or array of valid keys).返回一个对象的副本,筛选过滤,只有白名单键的值1 _.pick({name : 'moe', age: 50, userid : 'moe1'}, 'name', 'age');2 =& {name : 'moe', age : 50}源码: _.pick = function(obj) { var r
himanhimao 阅读(157) |
摘要: Copy all of the properties in thesourceobjects over to thedestinationobject, and return thedestinationobject. It's in-order, so the last source will override properties of the same name in previous arguments.将源对象属性复制到目标对象,并返回目标对象。它是有序的,所以最后的来源将覆盖以前参数名称相同的属性。1 _.extend({name : 'moe'}, {ag
himanhimao 阅读(374) |
摘要: Returns a sorted list of the names of every method in an object — that is to say, the name of every function property of the object.返回对象所包含的方法的列表,按A-Z排序.别名methods_.functions(_);=& [&all&, &any&, &bind&, &bindAll&, &clone&, &compact&, &qu
himanhimao 阅读(54) |
摘要: Return all of the values of theobject's properties.返回对象的所有属性的值1 _.values({one : 1, two : 2, three : 3});2 =& [1, 2, 3]源码:1 _.values = function(obj) {2 return _.map(obj, _.identity);3 };
himanhimao 阅读(48) |
摘要: Retrieve all the names of theobject's properties.返回对象的所有的属性名称1 _.keys({one : 1, two : 2, three : 3});2 =& [&one&, &two&, &three&]源码:1 _.keys = nativeKeys || function(obj) {2 if (obj !== Object(obj)) throw new TypeError('Invalid object');3 var keys = [];4
himanhimao 阅读(66) |
摘要: A function to create flexibly-numbered lists of integers, handy foreachandmaploops.start, if omitted, defaults to0;stepdefaults to1. Returns a list of integers fromstarttostop, incremented (or decremented) bystep, exclusive.建立一个包含指定范围单元的数组 1 _.range(10); 2 =& [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 3 _.ra
himanhimao 阅读(84) |
摘要: Returns the index of the last occurrence ofvaluein thearray, or-1if value is not present. Uses the nativelastIndexOffunction if possible返回值在数组中最后出现的位置,如果没有出现,返回-11 _.lastIndexOf([1, 2, 3, 1, 2, 3], 2);2 =& 4源码:1 _.lastIndexOf = function(array, item) {2 if (array == null) return -1;3 if (nat...
himanhimao 阅读(118) |
摘要: Returns the index at whichvaluecan be found in thearray, or-1if value is not present in thearray. Uses the nativeindexOffunction unless it's missing. If you're working with a large array, and you know that the array is already sorted, passtrueforisSortedto use a faster binary search.返回值在数组中首
himanhimao 阅读(176) |
摘要: Merges together the values of each of thearrayswith the values at the corresponding position. Useful when you have separate data sources that are coordinated through matching array indexes. If you're working with a matrix of nested arrays,zip.applycan transpose the matrix in a similar fashion将相对
himanhimao 阅读(106) |
摘要: Produces a duplicate-free version of thearray, using===to test object equality. If you know in advance that thearrayis sorted, passingtrueforisSortedwill run a much faster algorithm. If you want to compute unique items based on a transformation, pass aniteratorfunctio去除数组中重复的值,返回数组中所有唯一的值。别名unique_.
himanhimao 阅读(249) |
摘要: Similar towithout, but returns the values fromarraythat are not present in theotherarrays.返回数组中的差集_.difference([1, 2, 3, 4, 5], [5, 2, 10]);=& [1, 3, 4]源码:1 _.difference = function(array) {2 var rest = _.flatten(slice.call(arguments, 1), true);3 return _.filter(array, function(value){ retu...
himanhimao 阅读(669) |
摘要: Computes the list of values that are the intersection of all thearrays. Each value in the result is present in each of thearrays.返回数组的交集1 _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);2 =& [1, 2]源码:1 _.intersection = _.intersect = function(array) {2 var rest = slice.call(arguments, 1);3 ...
himanhimao 阅读(133) |
摘要: Computes the union of the passed-inarrays: the list of unique items, in order, that are present in one or more of thearrays.返回数组中的并集_.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);=& [1, 2, 3, 101, 10]源码:1 _.union = function() {2 return _.uniq(_.flatten(arguments, true));3 };
himanhimao 阅读(120) |
摘要: Returns a copy of thearraywith all instances of thevaluesremoved.===is used for the equality test移除数组中不需要的值,值的数量可以是N_.without([1, 2, 1, 0, 3, 1, 4], 0, 1);=& [2, 3, 4]源码: _.without = function(array) { return _.difference(array, slice.call(arguments, 1)); };
himanhimao 阅读(72) |
摘要: Flattens a nestedarray(the nesting can be to any depth). If you passshallow, the array will only be flattened a single level将多维嵌套数组转换成一维数组,如果shallow的值为true,数组嵌套级别只提升一级1 _.flatten([1, [2], [3, [[4]]]]);2 =& [1, 2, 3, 4];3 4 _.flatten([1, [2], [3, [[4]]]], true);5 =& [1, 2, 3, [[4]]]源码:1 _.flatt
himanhimao 阅读(143) |
摘要: Returns a copy of thearraywith all falsy values removed. In JavaScript,false,null,0,&&,undefinedandNaNare all falsy.返回的数组将不再包括,false,null,0,&&,undefined1 _.compact([0, 1, false, 2, '', 3]);2 =& [1, 2, 3]源码: _.compact = function(array) { return _.filter(array, function(
himanhimao 阅读(64) |
摘要: Returns therestof the elements in an array. Pass anindexto return the values of the array from that index onward返回数组中的元素的其余部分。通过索引返回数组中的值,从该指数开始. 别名tail_.rest([5, 4, 3, 2, 1]);=& [4, 3, 2, 1]源码: _.rest = _.tail = function(array, index, guard) { return slice.call(array, (index == null) || guard ?
himanhimao 阅读(70) |
摘要: Returns the last element of anarray. Passingnwill return the lastnelements of the array返回一个数组中的最后一个元素_.last([5, 4, 3, 2, 1]);=& 1源码: _.last = function(array, n, guard) { if ((n != null) && !guard) { return slice.call(array, Math.max(array.length - n, 0)); } else { return array[array...
himanhimao 阅读(91) |
摘要: initial_.initial(array, [n])Returns everything but the last entry of the array. Especially useful on the arguments object. Passnto exclude the lastnelements from the result.返回数组的所有元素,最后一个元素除外_.initial([5, 4, 3, 2, 1]);=& [5, 4, 3, 2] 源码: _.initial = function(array, n, guard) { return slice.call..
himanhimao 阅读(77) |
摘要: _.first(array, [n])Alias:headReturns the first element of anarray. Passingnwill return the firstnelements of the array返回数组的第一个元素. 别名head1 _.first([5, 4, 3, 2, 1]);2 =& 5源码: _.first = _.head = _.take = function(array, n, guard) { return (n != null) && !guard ? slice.call(array, 0, n) : arr
himanhimao 阅读(145) |热门关键字:
> Underscore.js
Underscore.js
作者:管理员发布时间: 10:05:35评论数:0
转载请自觉注明原文:
什么是Underscore
Underscore 是一个 工具库,它提供了一整套函数式编程的实用功能,但是没有扩展任何
内置对象。 他解决了这个问题:“如果我面对一个空白的 HTML 页面,并希望立即开始工作,我需要什么?” 他弥补了
没有实现的功能,同时又是
必不可少的部分。
Underscore提供了100多个函数:
集合(Collections)
- reduceRight
- findWhere
- contains
- partition
数组(Arrays)
- intersection
- difference
- lastIndexOf
- sortedIndex
函数(Functions)
- throttle
- debounce
对象(Objects)
- functions
- defaults
- property
- isElement
- isObject
- isArguments
- isFunction
- isString
- isNumber
- isFinite
- isBoolean
- isRegExp
- isUndefined
工具函数(Utility)
- noConflict
- identity
- constant
- iteratee
- uniqueId
- unescape
- template
链式语法(Chaining)
如果您觉得本文的内容对您的学习有所帮助:
相关文章:一个监控系统 我们今天要使用 underscore.js 和 jQuery 来构建一个客户端的应用,这个应用是一个监控系统的前端,设计师已经给出了界面设计:
而对应的服务器端的API也已经就绪了: $ curl http://localhost:9527/alarms.json -s | jq . 会看到诸如这样的返回值: [{&proiority&: &critical&,&occurrence&: &2/12/ AM&,&summary&: &heartbeat failure&,&node&: &VIQ002&},{&proiority&: &major&,&occurrence&: &2/12/ AM&,&summary&: &packages are rejected&,&node&: &VIQ002&},{&proiority&: &medium&,&occurrence&: &2/11/ AM&,&summary&: &connection cannot be established&,&node&: &VIQ002&}] 每条告警信息都包含:优先级,发生时间,描述信息,以及发生告警的节点名称。我们要将这些信息整合,并展示在页面上。mockup 我在《3周3页面》中讨论过现代前端开发的方式,你也可以参考这篇文章以及 这篇文章 。我们这里还是采用相同的方式来实现这个 mockup ,也就是静态页面。
首先我们在 index.html 中编写HTML:
&div class=&container&&&h1&Active Event List in transmission&/h1&&ul class=&events&&&li&&div class=&event critical&&&h3&heartbeat failure @ VIQ002&/h3&&span class=&date&&2/12/ AM&/span&&/div&&/li&&li&&div class=&event major&&&h3&packages are rejected&/h3&&span class=&date&&2/12/ AM&/span&&/div&&/li&&li&&div class=&event medium&&&h3&connection cannot be established&/h3&&span class=&date&&2/12/ AM&/span&&/div&&/li&&!-- ... --&&/ul&&ul class=&legend&&&li&&div class=&count critical&&&i class=&alarm&&&/i&&span&critical: 20&/span&&/div&&/li&&li&&div class=&count major&&&i class=&alarm&&&/i&&span&major: 13&/span&&/div&&/li&&li&&div class=&count medium&&&i class=&alarm&&&/i&&span&medium: 20&/span&&/div&&/li&&li&&div class=&count warning&&&i class=&alarm&&&/i&&span&warning: 30&/span&&/div&&/li&&li&&div class=&count indeterminate&&&i class=&alarm&&&/i&&span&indeterminate: 6&/span&&/div&&/li&&/ul&&/div&
events 中包含了所有告警信息,每一条告警根据等级不同显示了不同的颜色:红色表示严重,橘红表示主要,橘色表示一般等。告警信息包含了一个描述信息,并且包含了一个时间戳,表示告警发生的时间。
legend 部分是一个图例,其中包含了各个颜色的说明,并且包含了不同级别的告警信息的数目,比如截止目前为止,共有 20 个严重的告警,13个主要告警等。
对应的 scss 内容如下,首先定义了一些通用的CSS类:
@import &compass/reset&;@import &compass/css3&;body {font-size: 62.5%;font-family: &Open Sans&, serif;text-align: center;}.critical {background-color: red;color: white;}.major {background-color: orangered;color: white;}.medium {background-color: orange;color: white;}.warning {background-color: #2C75DB;color: white;}.indeterminate {background-color: #29D4BA;color: white;}
然后定义 container 中的各个元素的样式:
.container {padding: 1em 0;width: 800px;margin: 0 auto;h1 {font-size: 3em;text-transform: uppercase;margin: 1em 0;}.event {position: relative;h3 {text-align: left;font-size: 1.5em;padding: .6em .5em;text-transform: capitalize;}.date {position: absolute;top: 50%;right: 1em;font-size: 1em;font-style: italic;color: #eeeeee;}}.legend {margin: 1em 0;li {width: 20%;float: left;.count {padding: .6em;text-transform: capitalize;}}}} 应用程序 首先我们下载 underscore.js 和 jquery.js ,并将它们放在当前目录下的 scripts/libs 下,并在 scripts 下创建一个 app.js 文件。 这时候的目录结构如下: ├── index.html├── sass│ └── style.scss├── scripts│ ├── app.js│ └── libs│ ├── jquery.min.js│ └── underscore.js└── stylesheets└── style.css
然后我们在 index.html 中引入上列的文件:
&script src=&scripts/libs/jquery.min.js&&&/script&&script src=&scripts/libs/underscore.js&&&/script&&script src=&scripts/app.js&&&/script& 我们的应用程序需要做的事情很简单: 请求服务器获得数据 处理数据(如果需要的话) 将加工过的数据与模板结合,渲染在页面上 underscore.js 中有一个用来处理模板的函数,叫做 template :
var compiled = _.template(&&h1&&%= title %&&/h1&&);compiled({&title&: &Heartbeat Failure @ VIQ002&});//&h1&Heartbeat Failure @ VIQ002&/h1&
注意上式中的 &%= variable %& ,这个表达式表示打印 variable 的值。而如果只是执行JavaScript代码,表达式则为 &% %& 。
比如我们可以使用 for 循环:
var template =&&% _.each(alarms, function(alarm){ %&& +&&h3&&%= alarm.summary %&&/h3&& +&&% }); %&&;var compilded = _.template(template);compilded({&alarms&: [{&proiority&: &critical&,&occurrence&: &2/12/ AM&,&summary&: &heartbeat failure&,&node&: &VIQ002&},{&proiority&: &major&,&occurrence&: &2/12/ AM&,&summary&: &packages are rejected&,&node&: &VIQ002&},{&proiority&: &medium&,&occurrence&: &2/11/ AM&,&summary&: &connection cannot be established&,&node&: &VIQ002&}]});//&h3&heartbeat failure&/h3&&h3&packages are rejected&/h3&&h3&connection cannot be established&/h3&
注意上边代码中的 _.each 语句。 实现 首先我们在页面上定义一个模板,定义在id为 events 的 script 标签中,注意这个script的type为 template ,这样既可以避免浏览器解释它,又可以为我们临时保存一段文本。
&script type=&template& id=&events&&&% _.each(alarms, function(alarm) { %&&li&&div class=&event &%= alarm.proiority%&&&&h3&&%= alarm.summary%& @ &%= alarm.node %&&/h3&&span class=&date&&&%= alarm.occurrence %&&/span&&/div&&/li&&% }); %&&/script&
然后在 app.js 中只需要请求 alarms.json ,然后编译模板,并绑定数据:
$(function() {$.get(&/alarms.json&).done(function(alarms) {var compiled = _.template($(&#events&).html());var html = compiled({&alarms&: alarms});$(&.events&).html(html);});});
刷新页面,就可以看到来自于后台的实际数据了(当然,我们这里使用了一个静态的 alarms.json 来模拟后台的API):
处理数据你可能已经看到了,由于后台数据采集的问题,前端请求到的数据不一定每次都是按照日期排好序的,因此我们需要在拿到数据之后先排序在展示。好在我们之前已经学习了如何做到这一点: $(function() {$.get(&/alarms.json&).done(function(alarms) {var eventCompiled = _.template($(&#events&).html());var events = _(alarms).sortBy(&occurrence&).reverse();var eventHTML = eventCompiled({&alarms&: events});$(&.events&).html(eventHTML);});});
剩下的就是页面最底部的图例部分了,这部分会统计各种类型告警的合计信息,这些信息需要进一步的汇总。首先我们将 legend 封装成模板:
&script type=&template& id=&legend&&&% _.each(legends, function(legend) { %&&li&&div class=&count &%= legend.proiority %&&&&i class=&alarm&&&/i&&span&&%= legend.proiority %&: &%= legend.count %&&/span&&/div&&/li&&% }); %&&/script& 也即,我们需要这样一个结果集: [{&proiority&: &critical&,&count&: 3},{&proiority&: &major&,&count&: 2}]
不过使用 underscore.js ,我们可以很容易的得到这个格式的数据:
var legends = _.chain(alarms).groupBy(&proiority&).map(function(value, key) {return {proiority: key, count: value.length};}).value();
其中, groupBy 是一个新的API,和 SQL 中的 group by 子句一样,它可以将符合条件的项目合并为不同的组:
var contacts = [{&name&: &Juntao&,&age&: 29},{&name&: &Abruzzi&,&age&: 30},{&name&: &Sara&,&age&: 29}];var result = _(contacts).groupBy(&age&); 会得到这样的结果: {&29&: [{&name&: &Juntao&,&age&: 29},{&name&: &Sara&,&age&: 29}],&30&: [{&name&: &Abruzzi&,&age&: 30}]} 因此我们通过上面的计算就可以得到需要的结果了:}

我要回帖

更多关于 underscore.js教程 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信