vue 文件流下载xlsx 功能实现

downLoadFile (url, name) {
                this.xhr = new XMLHttpRequest()
                this.xhr.open('GET', url, true)
                this.xhr.responseType = 'blob'
                var vmThis = this
                this.xhr.onload = () => {
                    if (this.xhr.status === 200) {
                        if (this.xhr.response && this.xhr.response.size && this.xhr.response.size > 0) {
                            let file = this.xhr.response
                            let fileName = name
                            if ('msSaveOrOpenBlob' in navigator) {
                                window.navigator.msSaveOrOpenBlob(file, fileName)
                            } else {
                                let fileUrl = window.URL.createObjectURL(file)
                                let a = document.createElement('a')
                                a.download = fileName
                                a.href = fileUrl
                                document.getElementsByTagName('body')[0].appendChild(a)
                                a.click()
                                a.parentNode.removeChild(a)
                                window.URL.revokeObjectURL(fileUrl)
                            }
                        }
                    } else {
                        //
                    }
                }
                this.xhr.setRequestHeader('x-manage-token', this.$store.state.userInfo.data.sessionId)
                this.xhr.send()
            },
this.downLoadFile(this.url+'/authc/jzmOrder/exportJzmOrder','')

url 是后端接口全路劲 name 导出文件名称