0

我有一个不那么小的图像,我像这样预加载了它。

//cache the poster
var img = document.createElement("img");
img.src = "http://lorempixel.com/300/200";
// to make sure the poster is loaded before the video player appears
img.addEventListener("load", function() {
    //img loaded, show video
});
delete img;

上面的代码,在严格模式下给了我这个错误

严格模式下不允许对表达式调用 delete

我知道为什么在严格模式下不允许删除。我的查询是

  1. 这不会占用内存/资源空间吗?
  2. 如果是这样,有没有办法删除它?

PS: someObject.img = createElm 然后删除属性是更好的选择吗?

4

1 回答 1

-1

尝试做“删除”。我认为 img.remove() 有效

于 2016-08-11T22:14:21.767 回答