酒店预订平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

27 lines
585 B

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>compile-demo</title>
  6. <script src="../../dist/template-native.js"></script>
  7. </head>
  8. <body>
  9. <h1>在javascript中存放模板</h1>
  10. <div id="content"></div>
  11. <script>
  12. var source = '<ul>'
  13. + '<% for (var i = 0; i < list.length; i ++) { %>'
  14. + '<li>索引 <%= i + 1 %> :<%= list[i] %></li>'
  15. + '<% } %>'
  16. + '</ul>';
  17. var render = template.compile(source);
  18. var html = render({
  19. list: ['摄影', '电影', '民谣', '旅行', '吉他']
  20. });
  21. document.getElementById('content').innerHTML = html;
  22. </script>
  23. </body>
  24. </html>