我正在尝试通过编写一个小应用程序来学习淘汰赛。我的代码非常简单。我可能会犯一个小错误,所以我没有显示任何结果。有人可以帮忙吗?
以下是代码
Index.cshtml
<div>
<ul data-bind="foreach:list">
<li>
<span data-bind="text:name"></span>
</li>
</ul>
</div>
<script src="~/Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="~/Scripts/knockout-2.1.0.js" type="text/javascript"></script>
<script src="~/Content/MyScripts/PracticeScript.js" type="text/javascript"></script>
PracticeScript.js
$(function () {
var data = [
{ name: "microsoft" },
{ name: "google" },
{ name: "facebook" },
{ name: "twitter" },
{ name: "Apple" }
];
var viewModel = {
item: ko.observable(""),
list: ko.observableArray(data),
addNewItem: function () {
this.list.push(this.item());
}
};
ko.applyBindings(this.viewModel);
});