2015-12-17 25 views
0

这是示例Hello World小提琴的完整副本。我只是将它粘贴到我自己的小提琴中,并添加了对http://knockoutjs.com/downloads/knockout-3.2.0.js的引用。它适用于IE 11,但不适用于Chrome。它似乎没有解决淘汰赛参考。是否有一个或两个是Chrome专用的?jsFundle with Knockout在IE 11中工作,不在Chrome中

// Here's my data model var ViewModel = function(first, last) { this.firstName = ko.observable(first); this.lastName = ko.observable(last);

this.fullName = ko.computed(function() { 
    // Knockout tracks dependencies automatically. It knows that fullName depends on firstName and lastName, because these get called 

when evaluating fullName. return this.firstName() + " " + this.lastName(); }, this); }; ko.applyBindings(new ViewModel("Planet", "Earth")); // This makes Knockout get to work

https://jsfiddle.net/KellyWCline/rwL4rng9/2/

回答

0

这只是一个安全问题:出于安全考虑,Chrome浏览器从HTTP URL,当你是一个HTTPS页面内拒绝的脚本。包括从HTTPS网址类似https://cdnjs.com/libraries/knockout/3.2.0的淘汰赛,它将开始工作。

如果你曾考虑过Chrome的控制台,你会看到这样的错误:

Mixed Content: The page at ' https://fiddle.jshell.net/KellyWCline/rwL4rng9/2/show/ ' was loaded over HTTPS, but requested an insecure script ' http://knockoutjs.com/downloads/knockout-3.2.0.js '. This request has been blocked; the content must be served over HTTPS.

+0

谢谢你的链接。我可以分配它,当我点击它时,它会进入cdnjs页面。但是,当我运行jsfiddle(更新为/ 3)时,它仍然返回两个错误:第一个是Unexpected token <位于索引文件第一行(doctype.html声明)。第二个是'未定义'。 –

相关问题