2022-08-31 用iframe进行文件下载url

2022-08-31  本文已影响0人  流泪手心_521

                      updateDownloadCount(row.id).then(res => {
                if (res.status === 200) {
                        this.$Notice.success({
                            title: '成功',
                            desc: '下载成功'
                        })
                        if(row.downloadUrl){
                            var iframe = document.createElement('iframe')
                            iframe.src = row.downloadUrl // 文件地址
                            iframe.style.display = 'none'
                            iframe.onload = function () {
                                console.debug('start downloading...')
                                document.body.removeAttribute(iframe)
                            }
                            document.body.appendChild(iframe)
                        }
                        if(this.listForm.startTime){
                            this.listForm.startTime =  this.$Date(this.listForm.startTime).format('YYYY-MM-DD HH:mm:ss')
                        }
                        this.success=res.data //为了刷新页面
                    } else {
                        this.$Notice.error({
                            title: '失败',
                            desc: '下载失败'
                        })
                    }
            })

上一篇 下一篇

猜你喜欢

热点阅读