当前位置: 首页 > 科技观察

MobileFramework:简单而不简单的移动开发框架Lettuce_1

时间:2023-03-12 23:54:50 科技观察

Lettuce是一个小巧但功能强大的移动开发框架。在线演示:http://phodal.github.io/lettuce。示例1.创建一个新实例varL=newlettuce();2.定义数据vardata={about:"Template",what:"ThisaboutAMobileFrameworkForRomantic",why:"WhyisanewFramework"};3.创建路由函数functionabout(){varresult=L.tmpl("

{%=o.about%}

",data);document.getElementById("results").innerHTML=result;};functionwhat(){varresult=L.tmpl("

{%=o.what%}

",data);document.getElementById("results").innerHTML=result;}functionwhy(){varresult=L.tmpl("

{%=o.why%}

",data);document.getElementById("results").innerHTML=result;}4.添加routerL.Router。add(/#about/,about).add(/#what/,what).add(/#why/,why).load();处理完成模板路由器Ajax类承诺EventOnGoing模型简单视图varpageView=function(){};pageView.prototype={init:function(){varresult=L.tmpl("

"+this.message+"

",data);做cument.getElementById("results").innerHTML=result;}};varabout=newL.Class(pageView);about.prototype.message=data.about;varwhat=newL.Class(pageView);what.prototype.message=data.what;varwhy=newL.Class(pageView);why.prototype.message=data.why;许可证此代码是根据MIT许可证发布的,请参阅此目录lic??ense.txt。github:https://github.com/phodal/lettuce?2015PhodalHuang。