掃二維碼與項(xiàng)目經(jīng)理溝通
我們?cè)谖⑿派?4小時(shí)期待你的聲音
解答本文疑問(wèn)/技術(shù)咨詢/運(yùn)營(yíng)咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流
Lettuce是一個(gè)小巧而有力的移動(dòng)開發(fā)框架。

在線demo:http://phodal.github.io/lettuce.
1.新建實(shí)例
- var L = new lettuce();
2.定義數(shù)據(jù)
- var data = {
- about: "Template",
- what: "This about A Mobile Framework For Romantic",
- why: "Why is a new Framework"
- };
3.創(chuàng)建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許可下發(fā)布。看到這個(gè)目錄license.txt。
github:https://github.com/phodal/lettuce
? 2015 Phodal Huang.

我們?cè)谖⑿派?4小時(shí)期待你的聲音
解答本文疑問(wèn)/技術(shù)咨詢/運(yùn)營(yíng)咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流