groot 引入外部模板

index7.html

<html>
<head>
<title>groots引入外部模板van</title>
<script src="jquery-1.11.2.min.js"></script>
<script src="groot.js"></script>
<style>
.back0{
background-color: coral;
}
.back1{
background-color:forestgreen;
}
</style>
</head>
<body>
<div gt-view="myview">
<div gt-css="c(color,value)">hello word!</div>
<input gt-attr="uid(id,'view'+value)" type="text" gt-value-change="say"><span gt-text="'hello '+{say}"></span>
<div gt-include="./templ.html">

</div>
</div>
</body>
</html>
<script>
groot.view("myview", function (vm, ve) {
vm.list = [
{"name": "张三", "sex": "男"}
,{"name": "李四", "sex": "男"}
,{"name": "王五", "sex": "男"}
];
vm.uid = "123";
vm.say = "word";
vm.c="red"
})
</script>

模板内容

<ul gt-each="list">
<li gt-class="$index(back0:value % 2 ==0,back1:value % 2==1)"><span gt-text="{$index}+1"></span><span>姓名:</span><span
gt-text="{name}"></span>---<span>性别:</span><span
gt-text="{sex}"></span></li>
</ul>

 

引入外部模板指令gt-include="路径"; 路径的写法 类似 commonjs,"./“表示当前目录 ../ 表示上级目录 没有 ./ 和 ../ 表示从根目录开始

posted @ 2014-06-10 05:58  吹鱼算法  阅读(302)  评论(0编辑  收藏  举报