文件流转blob并播放

axios

  这里是请求了个mp3做例子;

this.$axios({
    methods:"GET",
    url:"/api/music/soures/双笙.mp3",
    responseType:'blob'
}).then(res=>{
    let blob=new Blob([res.data],{type:res.data.type});
    let url=window.URL.createObjectURL(blob);
    this.music=url
})

可能会遇到地址生成 但音视频并没有播放;

<video controls="" autoplay="" loop v-if="music">
    <source :src="music" type="audio/mpeg">
</video>
原文地址:https://www.cnblogs.com/1748sb/p/13873049.html