artTemplate嵌套使用

嵌套主要要用到
include


html > < html lang= "en" > < head > < meta charset= "UTF-8" > < title >Title title > < script type= "text/javascript" src= "../common/template.js" > script > head > < body > < div id= "content" > div > < script id= "test" type= "text/html" > < ul > {{each groups as value i}} < li > < h1 >{{value.groupName}} h1 > {{ include 'art4' value}} li > {{/each}} ul > script > < script id= "art4" type= "text/html" > {{each items as value i}} < div > appName: {{value.appName}} iconUrl: {{value.iconUrl}} div > {{/each}} script > < script type= "text/javascript" >
var data =
         {"groups":[
          {"groupName":"流程发起", 
          "items":[
          {"appName":"国内差旅","iconUrl":"pics/chailv.png","webUrl":"www.baidu.com"},
         {"appName":"国内差旅","iconUrl":"pics/chailv.png","webUrl":"www.baidu.com"},
         {"appName":"国内差旅","iconUrl":"pics/chailv.png","webUrl":"www.baidu.com"},
         {"appName":"国内差旅","iconUrl":"pics/chailv.png","webUrl":"www.baidu.com"},
         {"appName":"国内差旅","iconUrl":"pics/chailv.png","webUrl":"www.baidu.com"}]
                 },
       {"groupName":"员工服务",
             "items":[
             {"appName":"工资查询","iconUrl":"pics/chailv.png","webUrl":"www.baidu.com"},
            {"appName":"工资查询","iconUrl":"pics/chailv.png","webUrl":"www.baidu.com"}]
       },
       {"groupName":"员工1111111----服务",
         "items":[{"appName":"工资查询","iconUrl":"pics/chailv.png","webUrl":"www.baidu.com"},
            {"appName":"工资查询","iconUrl":"pics/chailv.png","webUrl":"www.baidu.com"}]
       }
   ],
"message":"请求成功"
     }
var html = template( 'test', data); document. getElementById( 'content'). innerHTML = html; script > body > html >

你可能感兴趣的:(artTemplate嵌套使用)