import axios from 'axios'

export default function fileDownLoad(path) {
    let urls = path.split('/');
    axios.create().get(path,{
        responseType: 'blob'
    }).then(res => {
            let blob = new Blob([res.data],{type:'application/download'});
            let objectUrl = URL.createObjectURL(blob);
            let a = document.createElement('a');
            a.download = urls[urls.length-1];
            a.href = objectUrl;
            a.click();
        }
    ).catch(e => {
        return e;
    })
}
Logo

前往低代码交流专区

更多推荐