我正在尝试在observableArray上执行ko.toJSON。它工作正常但似乎在从v.3.3.0更新到v.3.4.0后停止工作。我还没有尝试回滚确认,但我想问一下是否有人会对这个问题有解释。
我的observableArray声明:
self.items = ko.observableArray();
我的失败功能:
self.items.subscribe(function (items) {
localStorage.setItem("Cart", ko.toJSON(items));
});
我收到以下错误消息,我将其钉入ko.toJSON:
在Chrome上:
Uncaught SecurityError: Blocked a frame with origin "http://localhost:52519" from accessing a frame with origin "https://staticxx.facebook.com". The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "https". Protocols must match.
显然没有使用任何iframe而不是Facebook。
在Firefox上:
Error: Permission denied to access property "__ko_proto__"
a.Oa @ knockout-3.4.0.js:41
a.H @ knockout-3.4.0.js:41
(anonymous function) @ knockout-3.4.0.js:56
(anonymous function) @ knockout-3.4.0.js:55
c @ knockout-3.4.0.js:55
b @ knockout-3.4.0.js:55
(anonymous function) @ knockout-3.4.0.js:55
c @ knockout-3.4.0.js:55
b @ knockout-3.4.0.js:55
(anonymous function) @ knockout-3.4.0.js:55
c @ knockout-3.4.0.js:55
b @ knockout-3.4.0.js:55
(anonymous function) @ knockout-3.4.0.js:55
c @ knockout-3.4.0.js:55
b @ knockout-3.4.0.js:55
(anonymous function) @ knockout-3.4.0.js:55
c @ knockout-3.4.0.js:55
b @ knockout-3.4.0.js:55
(anonymous function) @ knockout-3.4.0.js:55
c @ knockout-3.4.0.js:55
b @ knockout-3.4.0.js:55
(anonymous function) @ knockout-3.4.0.js:55
c @ knockout-3.4.0.js:55
b @ knockout-3.4.0.js:55
(anonymous function) @ knockout-3.4.0.js:55
c @ knockout-3.4.0.js:55
b @ knockout-3.4.0.js:55
(anonymous function) @ knockout-3.4.0.js:55
c @ knockout-3.4.0.js:55
b @ knockout-3.4.0.js:55
(anonymous function) @ knockout-3.4.0.js:55
c @ knockout-3.4.0.js:55
b @ knockout-3.4.0.js:55
(anonymous function) @ knockout-3.4.0.js:55
c @ knockout-3.4.0.js:55
b @ knockout-3.4.0.js:55
(anonymous function) @ knockout-3.4.0.js:55
c @ knockout-3.4.0.js:55
b @ knockout-3.4.0.js:55
(anonymous function) @ knockout-3.4.0.js:55
c @ knockout-3.4.0.js:55
b @ knockout-3.4.0.js:55
(anonymous function) @ knockout-3.4.0.js:55
c @ knockout-3.4.0.js:55
b @ knockout-3.4.0.js:55
(anonymous function) @ knockout-3.4.0.js:55
c @ knockout-3.4.0.js:55
b @ knockout-3.4.0.js:55
a.wc @ knockout-3.4.0.js:56
a.toJSON @ knockout-3.4.0.js:56
(anonymous function) @ cart.js:118
notifySubscribers @ knockout-3.4.0.js:37
fa @ knockout-3.4.0.js:40
a.la.fn.(anonymous function) @ knockout-3.4.0.js:44
self.addItem @ cart.js:101
(anonymous function) @ knockout-3.4.0.js:89
dispatch @ jquery-2.1.4.min.js:3
r.handle @ jquery-2.1.4.min.js:3
items是CartItem的数组,它包含一些变量,observable和一个计算。
我希望有人有解释 谢谢你的帮助。
答案 0 :(得分:0)
我最后使用knockout.debug调试它。该错误与Developer Tools返回的错误消息无关。我的论点不正确,我的数组无法序列化 JavaScript之美。