我有一个背景图像存储在一个BLOB中,比如blob:http://lhost/3dbeb143-a618-46f3-8fa2-25f8dd477692
。
我想将一个元素的background-image
属性设置为这个blob。
我尝试将其设置为url("http://isequence/3dbeb143-a618-46f3-8fa2-25f8dd477692")
,但它只显示为isequence/3dbeb143-a618-46f3-8fa2-25f8dd477692: 404 Not Found
。显然,它正试图通过HTTP逐字请求该文件。
那么我该怎么做呢?
发布于 2017-01-25 05:52:59
试试这个:
<script>
var tmp_path = URL.createObjectURL('path/to/image.png');
document.getElementbyId('divId').style.background = tmp_path;
</script>
https://stackoverflow.com/questions/38810956
复制相似问题