vue 下载文件

    static download(data: any, name: string) {
        if (!data) {
            return;
    }
        const url = window.URL.createObjectURL(
            new Blob([ data ], {
                type: 'application/excel'
            })
        );
        const link = document.createElement("a");
        link.style.display = 'none';
        link.href = url
        link.download = name
        document.body.appendChild(link)
        link.click()
    }

你可能感兴趣的:(vue 下载文件)