下载导入模板
1.static
在static文件夹里面放入要下载的模板
2.需要模板的文件
function dataURLtoBlob(dataurl) {
const arr = dataurl.split(',')
const mime = arr[0].match(/:(.*?);/)[1]
const bstr = atob(arr[1])
let n = bstr.length
const u8arr = new Uint8Array(n)
while (n--) {
u8arr[n] = bstr.charCodeAt(n)
}
return new Blob([u8arr], {
type: mime
})
}
//下载导入模板
downloadExcel() {
const bloc = dataURLtoBlob(this.fileurl)
const blob = new Blob([bloc], {
type: 'application/vnd.ms-excel'
})
const downLoadEle = document.createElement('a')
// 通过返回的二进制数据来创建一个对象URL.
const href = URL.createObjectURL(blob)
downLoadEle.href = href
// 信息表为自定义文件名
downLoadEle.download = '党员管理数据导入模板.xlsx'
document.body.appendChild(downLoadEle)
downLoadEle.click()
document.body.removeChild(downLoadEle)
// 当加载完成后释放对象URL.
window.URL.revokeObjectURL(href)
// window.open(fileurl, '_blank')
},