IE8淘汰赛错误 - 无法处理绑定 [英] IE8 knockout error - Unable to process binding
问题描述
我有这样的viewmodel,
I have a viewmodel like this,
var sectorViewModel = function() {
this.currentValue = ko.observable();
this.previousValue = ko.observable();
....
this.maxValue = ko.computed(function() {
return Math.max(this.currentValue(), this.previousValue(), ...);
}, this);
}
ko.applyBinding(sectorVM, document.getElementById("divSector");
这是我正在进行数据绑定的html片段,
And this is the html snippet where I am doing the data-bind,
<div id="divSector">
...
<div class="bar" data-bind="style: {width: (currentValue()*100)/maxValue() + '%'}"></div>
...
</div>
在IE8以外的所有浏览器中都能正常工作。在IE8中,我在开发工具中看到此错误 -
Works fine in all browsers except for IE8. In IE8 I see this error in dev tool -
无效参数。无法处理绑定style:function(){return ...
任何想法如何让它在IE8中运行?
Any idea how can I get this to work in IE8?
谢谢。
推荐答案
调查从计算结果返回的确切结果。
Investigate the exact result that gets returned from your computed.
根据以下内容:
https://github.com/knockout/knockout/issues / 525
较新的浏览器可能会处理xx.asmanydecimalplacesrequired%等结果,但可能与IE8不兼容。您应该确保返回的值是IE8的兼容宽度样式属性 - 例如把它修剪到2位小数 - 这是我要尝试的第一件事。
The newer browsers probably handle a result such as xx.asmanydecimalplacesrequired% but may not be compatible with IE8. You should make sure the returned value is a compatible width style property for IE8 - e.g. trim it to 2 decimal places - that's the first thing I would try.
让我知道这是否有帮助,因为我通过研究完全搞清楚这一点,并且不要如果是这样的话,别忘记投票; P
Let me know if this helps, because I'm totally figuring this out via research, and don't forget to vote up if that's the case ;P
这篇关于IE8淘汰赛错误 - 无法处理绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!