EJS客户端浏览器运行

2018-01-24 15:31:00
admin
原创
551
<html>  
  <head> 
	<script src="http://code.ybao.org/demo/ejs/ejs.min.js"></script>  
    <script id="users" type="text/template">   
    <% if (names.length) { %>   
      <ul>    
        <% names.forEach(function(name){ %>    
          <li><%= name %></li>    
        <% }) %>   
	  </ul>   
	 <% } %>  
	</script>  
	<script>   
		onload = function(){   
			var users = document.getElementById('users').innerHTML;  
			var names = ['loki', 'tobi', 'jane'];   
			var html = ejs.render(users, { names: names });   
			document.body.innerHTML = html;   }  
	</script>  
  </head>  
  <body>  
  </body> 
</html>

  • QQ讨论群
  • 关注微信
    • 欢迎咨询
    • 欢迎加入QQ群 16506021
  • 公众号:源宝网络