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,"./“表示当前目录 ../ 表示上级目录 没有 ./ 和 ../ 表示从根目录开始

上一篇:MySqli 执行多条SQL语句


下一篇:Android --http请求之HttpURLConnection