推薦js庫: underscore

來源:互聯網
上載者:User

標籤:效果   入門   之間   推薦   i++   ++   hive   元素   國內   

Underscore封裝了常用的JavaScript對象操作方法,用於提高開發效率。

之間沒用他之前,自己寫,那是相當的酸爽。

如迴圈處理:

for(var i=0;i<data.length;i++){    // TODO    }

用他

_.each(data,function(item){    // TODO})

 

如要刪掉資料中的某條

data = _.reject(data,function(item){    return item.id =  要刪的資料id})    

 

還有很多,需要自己去體會,用了都知道很hign

附上api,日常也可查看下

英文的 :  http://underscorejs.org/

國內翻譯的: http://www.css88.com/doc/underscore/

-------------

ps: 官網的左側有個過濾搜尋,挺好,思路不錯,也可自己查看下源碼

效果:

 

查詢map

 

再看下他的main.js 的實現

 

實現思路大致如下:

1. 監聽上面這個輸入框,如有變化,調用1個方法

2. 方法中拿到左側列表的元素,比對,算出哪些要隱藏掉。

----------------------------------------------------

 

 

 

 

下面是簡單入門介紹,就不搬內容了,可過去看

--------------------------------

Underscore.js 入門     http://www.css88.com/archives/4728

Underscore.js 入門-常用方法介紹      http://www.css88.com/archives/4784

推薦js庫: underscore

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.