ejs.compile 编译字符串得到模板函数

2018-01-24 16:29:00
admin
原创
570
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<div id="div1"></div>
<div id="div2"></div>
<div id="div3"></div>
<script src="/demo/ejs/ejs.min.js"></script>
<script>
    var html = ejs.render('<%=123 %>','');
	var template = ejs.compile('<%=456 %>');
    var result = template();
    //console.log(result);//123
    document.getElementById('div1').innerHTML = template;
	document.getElementById('div2').innerHTML = result;
	document.getElementById('div3').innerHTML = html;
</script>
</body>
</html>

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