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.

THE END