代码拉取完成,页面将自动刷新
<!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>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。