Javascript IE中的敲除JS 2.0绑定解析错误

Javascript IE中的敲除JS 2.0绑定解析错误,javascript,internet-explorer,knockout.js,Javascript,Internet Explorer,Knockout.js,有人能告诉我这有什么问题吗?它在Chrome/Firefox中运行良好,但在IE 8中我遇到以下错误: Message: Unable to parse bindings. Message: SyntaxError: Expected identifier, string or number; Bindings value: click: blah, attr: {class: 'Hi'} Line: 38 Char: 359 Code: 0 URI: http://cdnjs.cloudfla

有人能告诉我这有什么问题吗?它在Chrome/Firefox中运行良好,但在IE 8中我遇到以下错误:

Message: Unable to parse bindings.
Message: SyntaxError: Expected identifier, string or number;
Bindings value: click: blah, attr: {class: 'Hi'}
Line: 38
Char: 359
Code: 0
URI: http://cdnjs.cloudflare.com/ajax/libs/knockout/2.0.0/knockout-min.js

class
放在引号中。我在使用保留字时遇到了同样的问题

attr: {'class': 'Hi'}

Daniel A.White已经指出了您的具体问题,但是如果您要定期使用CSS类,我建议您使用
CSS
绑定


利润信息
var viewModel={
currentProfit:ko.observable(150000)//正值,因此最初我们不应用“profitWarning”类
};
viewModel.currentProfit(-50);//导致应用“profitWarning”类

谢谢你,这救了我一天!这也适用于
if
。万一有人发现这个页面和我有同样的问题。@RichardDalton:你说它适用于if是什么意思?例如:如果PropertyName==1&&SubCollection.length?是否应为“PropertyName”?对于次收集,长度是多少?问是因为我对IE8的淘汰2.3.0有些问题。预期的标识符、字符串或数字行2000我将所有属性也放在if中的引号中。同样的废话(我真的很讨厌IE):(@firepol我的意思是当你在做
data bind=“if:something”
。if应该像
data bind=“'if':something”那样引用
@richarddolton谢谢,你是唯一一个指出“如果”:某个问题的人。你知道在这种情况下,这似乎只是我目前在这行的一个问题
ko template:{name:'conversation template',data:negotiation,'if':negotiation()。conversation
<div data-bind="css: { profitWarning: currentProfit() < 0 }">
   Profit Information
</div>

<script type="text/javascript">
    var viewModel = {
        currentProfit: ko.observable(150000) // Positive value, so initially we don't apply the "profitWarning" class
    };
    viewModel.currentProfit(-50); // Causes the "profitWarning" class to be applied
</script>