我只是希望得到一个简单的打字稿淘汰示例。我已经使用nugget获取打字稿淘汰赛并已下载淘汰赛3.0.0 js。这是我的打字稿文件
declare var ko;
class AppViewModel {
firstName = ko.observable("Bob");
lastName = ko.observable("Newhart");
}
ko.applyBindings(new AppViewModel());
这是我的HTML
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>TypeScript HTML App</title>
<link rel="stylesheet" href="app.css" type="text/css" />
<script type='text/javascript' src='Scripts/knockout-3.0.0.js'></script>
<script src="AppViewModel.js"></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>
我是否正确引用了淘汰库?我正确地调用了ko.applyBindings吗?
为了完整性,这里是生成的javascript
var AppViewModel = (function () {
function AppViewModel() {
this.firstName = ko.observable("Bob");
this.lastName = ko.observable("Newhart");
}
return AppViewModel;
})();
ko.applyBindings(new AppViewModel());
//# sourceMappingURL=AppViewModel.js.map