我可以在http://learn.knockoutjs.com/#/?tutorial=intro上做在线教程,但是当我尝试在一个空的 ASP.NET 项目的 HTML 页面中做同样的事情时,它就不起作用了。为什么?
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="Scripts/knockout-2.3.0.js"></script>
<script type="text/javascript">
function AppViewModel() {
this.firstName = "Bert";
this.lastName = "Bertington";
}
ko.applyBindings(new AppViewModel());
</script>
</head>
<body>
<p>First name: <strong data-bind="text: firstName"></strong></p>
<p>Last name: <strong data-bind="text: lastName"></strong></p>
</body>
</html>