【vue】后端接口返回了在预览中展示的png(二进制流)如何展示在前端页面?

代码

  created() {
    axios({
      url: "http://localhost:8080/img/getimg",
      responseType: "blob", //关键
    }).then((res) => {
      let data = new Blob([res.data]);
      let url = window.URL.createObjectURL(data);
      this.image = url; //image是图片的路径
    });
  },
posted @ 2022-11-19 11:36  小罗要有出息  阅读(804)  评论(0编辑  收藏  举报