可以使用Blob对象的URL.createObjectURL()方法将Blob对象转换为URL,然后创建一个链接下载或者直接打印到控制台。

示例代码:

axios.get('/public/mock/1683616705171.mp3',{
    responseType:'blob'
}).then(response => {
    const blob = new Blob([response.data], {type: 'audio/mp3'});
    const url = URL.createObjectURL(blob);
    console.log(url); // 打印URL到控制台
    // 创建一个链接下载
    const link = document.createElement('a');
    link.href = url;
    link.download = 'audio.mp3';
    link.click();
});
axiosgetpublicmock1683616705171mp3 responseTypeblob 我想将这个blob数据保存并打印到控制台

原文地址: http://www.cveoy.top/t/topic/eYZ8 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录