2 Star 0 Fork 0

mirrors_hacke2/GhostJS

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test.html 1.71 KB
一键复制 编辑 原始数据 按行查看 历史
YiJun 提交于 2014-10-29 21:06 +08:00 . Obj function Bind with this Obj
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ghost Template</title>
<script type="text/javascript" src="../ghost0.0.3.js"></script>
</head>
<body>
<button id="btn">Click</button>
<div id="list"></div>
<div class="divblock"></div>
<div class="divblock"></div>
<script type="text/javascript">
Go(function(){
// 我就看看中文会不会乱码
// G {{ Template }} base on Underscore Template
// fast {{ Building }} the Template at once
// you {{ need }} write word like this
var tplBuilding =
''
+ '<ol>'
+ '{{ data = data["list"]; }}'
+ '{{ DataList = JSON.parse(decodeURIComponent(data)); }}'
+ '{{ console.log(DataList); }}'
+ '{{ Go.ObjEach(DataList,function(item){ }}'
+ '<li>{{= item.lag }}</li>'
+ '<li>{{= item.autor }}</li>'
+ '{{ }) }}'
+ '</ol>'
+ '{{ Go("#btn").unbind(); }}';
var tpl = Go.template(tplBuilding,{ variable:"data" });
Go("#btn").bind("click",function(){
Go.JSONP({
url : "http://jsfiddle.Net/echo/jsonp",
data : { 'list': '{ "1":{"lag":"JavaScript","autor":"Ghost" }, "2":{"lag":"C++","autor":"Demon"} }' },
fail : function(e){ alert(e); },
success : function(data){ Go("#list .divblock").insetHTML(tpl(data)) }
});
});
this.x = 9;
var module = {
x: 81,
getX: function(a,b,c,d,e) { console.log(arguments); console.log(this.x) }
};
var getX = module.getX;
getX(); // 9, because in this case, "this" refers to the global object
// Create a new function with 'this' bound to module
boundGetX = Go.FuncBind(module.getX,module,[9,10,11]);
boundGetX(1,2,3,4,5,6,7,8); // 81
});
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_hacke2/GhostJS.git
git@gitee.com:mirrors_hacke2/GhostJS.git
mirrors_hacke2
GhostJS
GhostJS
master

搜索帮助