How can projects on vue mobile download .doc files? Download has poor compatibility on mobile, can't it be used?

is there a ready-made solution, or a good idea,

Apr.19,2021

distinguish whether the file stream returned by the back end or directly trigger the link to download?

if the link download is triggered directly, it is very simple

if it is a file stream, the front end needs to do another processing before downloading
my sample code is axios, for your reference

1 triggers the download API. To set responseType = 'blob'
in axios, refer to the official document https://github.com/axios/axios

.

2 write a function that accepts the file stream

// blob 
// blob  fileName 
function downFiles(blob, fileName) {
    let link = document.createElement('a')
    link.href = window.URL.createObjectURL(blob)
    link.download = fileName
    link.click()
    window.URL.revokeObjectURL(link.href)
}
 

3 there is also some processing to be done in the callback function that sends the request, for example, I want to trigger the xx/down interface

api("down", formData, "post", "blob").then(function(res) {
                let blob = new Blob([res.data], {
                    type: '*'
                })
                let fileName = ''
                _this.$tool.downFiles(blob, fileName)
                _this.isDown = false
            })

https://www.cnblogs.com/webbe.
https://www.zhangxinxu.com/wo.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b33f6a-4d574.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b33f6a-4d574.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?