错误打印:
Error: You must pass a string or Handlebars AST to Handlebars.compile
出现这个错误我是因为var tpl =$("guestList").html那里没有写(), 在网上复制后没注意。
正确的:
<!DOCTYPE html>
<html>
<head>
<script src="ui/jquery-3.4.1.js"></script>
<script src="ui/handlebars-v4.1.2.js"></script>
</head>
<body>
<div class="guest_ul">
</div>
</body>
<script type="text/template" id="guestList">
{{value}}
</script>
<script type="text/javascript">
var tpl =$('#guestList').html();
var template = Handlebars.compile(tpl);
var data={ value:'12312' }
var html = template(data);
$('.guest_ul').html(html);
</script>
</html>