Mobile Framework:簡約不簡單的移動開發架構Lettuce

來源:互聯網
上載者:User

Mobile Framework:簡約不簡單的移動開發架構Lettuce

Lettuce是一個小巧而有力的移動開發架構。

線上demo:http://phodal.github.io/lettuce.

樣本

1.建立執行個體

 
  1. var L = new lettuce(); 

2.定義資料

 
  1. var data = { 
  2.     about: "Template", 
  3.     what: "This about A Mobile Framework For Romantic", 
  4.     why: "Why is a new Framework" 
  5. }; 

3.建立router功能

 
  1. function about() { 
  2.     var result = L.tmpl("<h3>{%=o.about%}</h3>", data); 
  3.     document.getElementById("results").innerHTML = result; 
  4. }; 
  5.  
  6. function what() { 
  7.     var result = L.tmpl("<h3>{%=o.what%}</h3>", data); 
  8.     document.getElementById("results").innerHTML = result; 
  9.  
  10. function why() { 
  11.     var result = L.tmpl("<h3>{%=o.why%}</h3>", data); 
  12.     document.getElementById("results").innerHTML = result; 

4.添加router

 
  1. L.Router 
  2.     .add(/#about/, about) 
  3.     .add(/#what/, what) 
  4.     .add(/#why/, why) 
  5.     .load(); 
過程Done
  • Template
  • Router
  • Ajax
  • Class
  • Promise
  • Event
On Going
  • Model
簡單視圖
 
  1. var pageView = function(){}; 
  2. pageView.prototype = { 
  3.     init:function(){ 
  4.         var result = L.tmpl("<h3>" + this.message + "</h3>", data); 
  5.         document.getElementById("results").innerHTML = result; 
  6.     } 
  7. }; 
  8.  
  9. var about = new L.Class(pageView); 
  10. about.prototype.message = data.about; 
  11.  
  12. var what = new L.Class(pageView); 
  13. what.prototype.message = data.what; 
  14.  
  15. var why = new L.Class(pageView); 
  16. why.prototype.message = data.why; 
許可

此代碼是在MIT許可下發布。看到這個目錄license.txt。

github:https://github.com/phodal/lettuce

© 2015 Phodal Huang.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.