在控制台中显示此错误消息
未捕获的TypeError:$。link不是6.html的函数:17。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script src="jsrender-master/jsrender.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
<script src="jsViews.js"></script>
</head>
<body>
<label><input data-link="show" type="checkbox"/> Show</label>
<div data-link="{if show tmpl='show this'}{else tmpl='no show'}"></div>
<script>
$.link(true, "body", {show: true});
</script>
</body>
</html>
答案 0 :(得分:1)
您必须包含这三个文件,否则它无法正常工作。
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsrender/0.9.90/jsrender.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsviews/0.9.90/jquery.observable.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsviews/0.9.90/jquery.views.min.js"></script>
或者你可以用一个文件jsviews.js替换jsrender.js:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsviews/0.9.90/jsviews.min.js"></script>