扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
Lettuce是一个小巧而有力的移动开发框架。
在线demo:http://phodal.github.io/lettuce.
1.新建实例
- var L = new lettuce();
2.定义数据
- var data = {
- about: "Template",
- what: "This about A Mobile Framework For Romantic",
- why: "Why is a new Framework"
- };
3.创建router功能
- function about() {
- var result = L.tmpl("
{%=o.about%}
", data);- document.getElementById("results").innerHTML = result;
- };
- function what() {
- var result = L.tmpl("
{%=o.what%}
", data);- document.getElementById("results").innerHTML = result;
- }
- function why() {
- var result = L.tmpl("
{%=o.why%}
", data);- document.getElementById("results").innerHTML = result;
- }
4.添加router
- L.Router
- .add(/#about/, about)
- .add(/#what/, what)
- .add(/#why/, why)
- .load();
- var pageView = function(){};
- pageView.prototype = {
- init:function(){
- var result = L.tmpl("
" + this.message + "
", data);- document.getElementById("results").innerHTML = result;
- }
- };
- var about = new L.Class(pageView);
- about.prototype.message = data.about;
- var what = new L.Class(pageView);
- what.prototype.message = data.what;
- var why = new L.Class(pageView);
- why.prototype.message = data.why;
此代码是在MIT许可下发布。看到这个目录license.txt。
github:https://github.com/phodal/lettuce
© 2015 Phodal Huang.
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流