JavaScript的MVC 框架,Mithril.js 0.1.29 發布

jopen 9年前發布 | 8K 次閱讀 MVC

Mithril.js 0.1.29 發布,現已提供下載(ZIP)。

Mithril.js 是一個客戶端的 JavaScript MVC 框架。可將應用分成數據層、UI層和控制層。Mithril 壓縮后只有 3kb 左右。API 提供一個模板引擎,帶 DOM diff 實現,支持路由和組合。

What is Mithril?

Mithril is a client-side MVC framework - a tool to organize code in a way that is easy to think about and to maintain.

Light-weight

  • Only 5kb gzipped, no dependencies
  • Small API, small learning curve

Robust

  • Safe-by-default templates
  • Hierarchical MVC via components

Fast

  • Virtual DOM diffing and compilable templates
  • Intelligent auto-redrawing system
//namespace
var app = {};

//model
app.PageList = function() {
    return m.request({method: "GET", url: "pages.json"});
};

//controller
app.controller = function() {
    this.pages = app.PageList();
};

//view
app.view = function(ctrl) {
    return ctrl.pages().map(function(page) {
        return m("a", {href: page.url}, page.title);
    });
};

//initialize
m.module(document.getElementById("example"), app);

JavaScript的MVC 框架,Mithril.js 0.1.29 發布

http://lhorie.github.io/mithril/

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