axios输出图片显示

时间:2021-01-05 11:39:07   收藏:0   阅读:0
  1. 获取response并创建一个静态的DOMString
    this.axios.get(url,{
    responseType: ‘blob‘
    }).then(res) {
    var src = window.URL.createObjectURL(res.data);
    //src 就是一个可以显示图片的相对路径。因为window.URL.crateObjectURL(blob)已经进行了转换
    }
  2. 将src绑定在页面img标签的src属性上。
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!