Javascript 无法在html中调用.js(使用敲除)

Javascript 无法在html中调用.js(使用敲除),javascript,html,knockout.js,knockout-2.0,Javascript,Html,Knockout.js,Knockout 2.0,我不熟悉使用knockout2.1.0进行淘汰赛。 我有一个外部java脚本文件,但它没有在我的html文件中调用。我不明白 我在我的html文件中添加了以下内容 <script src="Scripts/TestJavascript.js"></script> JS文件 ///<reference path="~/Scripts/jquery-1.8.1.min.js"> ///<reference path="~/Scripts/knock

我不熟悉使用knockout2.1.0进行淘汰赛。 我有一个外部java脚本文件,但它没有在我的html文件中调用。我不明白

我在我的html文件中添加了以下内容

  <script src="Scripts/TestJavascript.js"></script>

JS文件

///<reference path="~/Scripts/jquery-1.8.1.min.js">
///<reference path="~/Scripts/knockout-2.1.0.debug.js">
$(function AppViewModel() {
this.firstName = ko.observable("rash");
this.lastName = ko.observable("Bertington");
this.fullName = ko.computed(function(){
    return this.firstName() + " " + this.lastName();
}, this);
})
ko.applyBindings(new AppViewModel());
///
///
$(函数AppViewModel(){
this.firstName=ko.可观察(“鲁莽”);
this.lastName=ko.observable(“伯丁顿”);
this.fullName=ko.computed(函数(){
返回此.firstName()+“”+此.lastName();
},这个);
})
应用绑定(新的AppViewModel());

谢谢。

您没有创建ViewModel。您正在将其传递给jquery

试一试


您没有创建ViewModel。您正在将其传递给jquery

试一试


此代码必须出现在绑定的html之后,或者出现在文档就绪事件(jquery)中


此代码必须出现在绑定的html之后,或者出现在文档就绪事件(jquery)中


我无意让人觉得你很严厉,但你的问题让人很困惑。。也许你能提供一些更相关的代码吗?我不想给人留下苛刻的印象,但你的问题很令人困惑。。你能提供一些更相关的代码吗?
var AppViewModel = function() {
  this.firstName = ko.observable("rash");
  this.lastName = ko.observable("Bertington");
  this.fullName = ko.computed(function(){
      return this.firstName() + " " + this.lastName();
  }, this);
})
ko.applyBindings(new AppViewModel());
function AppViewModel() {
    this.firstName = ko.observable("rash");
    this.lastName = ko.observable("Bertington");
    this.fullName = ko.computed(function(){
        return this.firstName() + " " + this.lastName();
    }, this);
};
ko.applyBindings(new AppViewModel());