javascript 类型错误:试图分配给只读属性。在 iOS8 Safari 上
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25174594/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
TypeError: Attempted to assign to readonly property. on iOS8 Safari
提问by mko
Hi this pageon my site works fine on desktop browser, but has a weird bug on iOS8 Safari:
嗨,我网站上的这个页面在桌面浏览器上运行良好,但在 iOS8 Safari 上有一个奇怪的错误:
The index template doesn't show up, and there's a error in the console:
索引模板不显示,控制台报错:
TypeError: Attempted to assign to readonly property.
类型错误:试图分配给只读属性。
and it points to the following line:
它指向以下行:
}), e("rsvp/promise/all", ["../utils", "exports"], function(e, t) {
"use strict";
var r = e.isArray, n = e.isNonThenable;
t["default"] = function(e, t) {
var i = this;
return new i(function(t, a) {
function o(e) {
return function(r) {
c[e] = r, 0===--u && t(c)
}
}
function s(e) {
u = 0, a(e)
}
if (!r(e))
throw new TypeError("You must pass an array to all.");
var l, u = e.length, c = new Array(u);
if (0 === u) // This is the line with error
return void t(c);
for (var h = 0; h < e.length; h++)
l = e[h], n(l) ? (c[h] = l, 0===--u && t(c)) : i.cast(l).then(o(h), s)
}, t)
}
}), e("rsvp/promise/cast", ["exports"], function(e) {
"use strict";
Is it a known bug to mobile safari, is there fix of it?
这是移动 safari 的已知错误,有修复吗?
回答by Stefan Penner
Maintainer of RSVP here, sorry that you ran into this issue.
RSVP 的维护者在这里,很抱歉您遇到了这个问题。
Firstly, it appears you are using an older version of RSVP. I would recommend upgrading.
首先,您似乎使用的是旧版本的 RSVP。我会建议升级。
Unfortunately it appears this issue may be related to https://github.com/emberjs/ember.js/pull/5629which appearsto just be that JSC for non-64bit devices running iOS 8 is just broken when in 'use strict' mode. In my observations it only happens in specific situations and then only when the code in question has become optimized.
不幸的是,这个问题似乎与https://github.com/emberjs/ember.js/pull/5629有关,这似乎只是运行 iOS 8 的非 64 位设备的 JSC 在“严格使用”时被破坏了模式。根据我的观察,它只发生在特定情况下,然后只有当有问题的代码已经优化时才会发生。
Again I am unsure if upgrading will help you, but you should consider it regardless. Additionally, if the problem persists removing all use strict
statements may be the best option.
我再次不确定升级是否对您有帮助,但无论如何您都应该考虑一下。此外,如果问题仍然存在,删除所有use strict
语句可能是最佳选择。
If no solution appears soon, I will likely publish an update to RSVP with the use strict statements removed.
如果很快没有解决方案出现,我可能会发布更新到 RSVP 并删除 use strict 语句。
回答by peer
Have you tried to remove all the "use strict";
's from your code? From my understanding it only seems to occur with 3. generation iPads.
您是否尝试"use strict";
从代码中删除所有 's ?根据我的理解,它似乎只发生在第 3 代 iPad 上。