Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

接口返回的Preview是一张图片,但vue怎么渲染到页面呢?

如图接口返回一张图片
image.png

打印是对象数据:
image.png

image.png
但怎么渲染到vue的DOM上呢?试过img标签不行,有没有知道的高手呢?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

URL.createObjectURL(blob) 然后用得到的地址去给img的src赋值

上述可以得到一个 bloburl

你也可以绘制在canvas上面。然后拿base64

如果你的接口要不要request headers,那么你完全可以用img的src请求你的接口。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...