Baixe o arquivo e abra o arquivo
API de amostra
wx.downloadFile({
url: 'https://example.com/audio/123',
success (res) {
if (res.statusCode === 200) {
wx.playVoice({
filePath: res.tempFilePath
})
}
}
})
wx.downloadFile({
url: 'http://example.com/somefile.pdf',
success: function (res) {
const filePath = res.tempFilePath
wx.openDocument({
filePath: filePath,
success: function (res) {
console.log('打开文档成功')
}
})
}
})
Código de exemplo do projeto
wx.downloadFile({
url: this.data.homeworkPicture,
success: function (res) {
var filePath = res.tempFilePath
wx.openDocument({
filePath: filePath,
success: function (res) {
console.log('打开文档成功')
}
})
}
})