【发布时间】:2016-05-31 11:33:51
【问题描述】:
我在输入类型文件上使用 URL.createObjectURL() 将 URL 传递给 img.src 以告诉浏览器加载提供的图像。
这是我的代码:
<input type="file" accept="image/*" onchange="document.getElementById('image-container').src = window.URL.createObjectURL(this.files[0])">
<img id="image-container"/>
我想制作一个删除按钮来清除对象,以便用户可以浏览其他图像。我试图通过制作 .src = "" 来传递空字符串,但它不起作用。
<button type="button" ng-click="document.getElementById('image-container').src = ""><span aria-hidden="true">×</span></button>
如果我坚持继续使用 URL.createObjectURL(),谁能建议我应该怎么做才能删除创建的对象?
【问题讨论】:
标签: javascript angularjs html