美文网首页我爱编程
在safari10以下 报错attempted to assig

在safari10以下 报错attempted to assig

作者: 代小代isDelenDelen | 来源:发表于2018-02-13 16:11 被阅读895次

翻译为:尝试分配定义只读属性

let dom = document.getElementById('pageLoading')
dom.style= 'display:none; opacity: 1;'

对于以上代码,safari10会报错,出现attempted to assign to readonly property
TrackJS指出,这个报错是一个 ios中webkit内核的bug(而且每个框架都以独特的方式遇到这个问题.

dom.style.display = 'none';
dom.style.opacity =1

给DOM元素,使用同样方法设置style属性,并不会报错。
webkit bugs 也确认了该问题,在stackoverflow里也看到其它框架也有类似问题,Angular以及vue.esm.js等。后来发现直接删除js开头的'use strict';就不会报错了,但是这样js语法就不是严格模式了。

参考文档:

IOS设备 出现 attempted-to-assign-to-readonly-property 报错

相关文章

网友评论

    本文标题:在safari10以下 报错attempted to assig

    本文链接:https://www.haomeiwen.com/subject/gcgjtftx.html