Lettuce开发框架怎么使用
这篇文章主要介绍“Lettuce开发框架怎么使用”,在日常操作中,相信很多人在Lettuce开发框架怎么使用问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Lettuce开发框架怎么使用”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
Lettuce是一个小巧而有力的移动开发框架。

示例
1.新建实例
varL=newlettuce();
2.定义数据
vardata={about:"Template",what:"ThisaboutAMobileFrameworkForRomantic",why:"WhyisanewFramework"};
3.创建router功能
functionabout(){varresult=L.tmpl("<h4>{%=o.about%}</h4>",data);document.getElementById("results").innerHTML=result;};functionwhat(){varresult=L.tmpl("<h4>{%=o.what%}</h4>",data);document.getElementById("results").innerHTML=result;}functionwhy(){varresult=L.tmpl("<h4>{%=o.why%}</h4>",data);document.getElementById("results").innerHTML=result;}
4.添加router
L.Router.add(/#about/,about).add(/#what/,what).add(/#why/,why).load();
简单视图
varpageView=function(){};pageView.prototype={init:function(){varresult=L.tmpl("<h4>"+this.message+"</h4>",data);document.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;
到此,关于“Lettuce开发框架怎么使用”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注恰卡编程网网站,小编会继续努力为大家带来更多实用的文章!