error - ie strict 模式下不允许分配到只读属性

error - ie strict 模式下不允许分配到只读属性

原因

img.style = 'width:100%;height:100%;display:inline-block;position:relative;z-index:0;'; // strict 模式下不允许分配到只读属性

解决

将css属性拆分开依次设置属性值即可。

img.style.width = '100%';
img.style.height = '100%';
Object.assign(img.style, {
width: '100%',
height: '100%',
display: 'inline-block',
position: 'relative',
zIndex: 0,
});
posted @   zc-lee  阅读(232)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示