用于創建數據驅動組件的簡潔、靈活的前端框架:Regularjs

jopen 10年前發布 | 24K 次閱讀 Regular 前端技術

Regularjs是一個用于創建數據驅動組件的簡潔、靈活的前端框架,擁有強大的實時模板引擎幫助我們創建交互式組件。基于MVVM 模式創建組件。數據綁定,指令,過濾器,事件和動畫...都支持開箱即用簡潔的API。完全自成一體,易于集成和封裝好。使其對大項目友好。
regular-icon-neg.png

特性:

  1. data-binding based on dirty-check
  2. string-based template
  3. independent lifecycle —— can be integrated with whatever framework you already used.
  4. nested component
  5. class-based component. just like angular-classy do for angular
  6. powerfull animation supported (blog)
  7. directive, filter, event is supported, and extend easily.

template

{{#list notes as c}}
  <p>{{c.content}}<a href='#' on-click={{this.remove(c)}}>remove</a></p>
{{/list}}
<textarea r-model={{draftComment}}></textarea>
<button on-click={{this.add()}}>new Note</button>

javascript

var NoteApp = Regular.extend({
  template: "#todos",
  remove: function(index){
    this.data.notes.splice(index,1);
  },
  add: function(){
    var data = this.data;
    data.notes.push({ content: data.draftComment})
    data.draftComment = "";
  }
});

new NoteApp({ data: {notes:[] }}).inject(document.body);

項目主頁:http://www.baiduhome.net/lib/view/home/1408606062334

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!