wx.opendocument微信小程序新開(kāi)頁(yè)面打開(kāi)文檔怎么做
2020-12-07
導(dǎo)讀:wx.openDocument(OBJECT) 新開(kāi)頁(yè)面打開(kāi)文檔,支持格式:doc, xls, ppt, pdf, docx, xlsx, pptx OBJECT參數(shù)說(shuō)明: 參數(shù) 說(shuō)明 必填 說(shuō)明 最低版本 filePath String 是 文件路徑,可...
wx.openDocument(OBJECT)
新開(kāi)頁(yè)面打開(kāi)文檔,支持格式:doc, xls, ppt, pdf, docx, xlsx, pptx
OBJECT參數(shù)說(shuō)明:
參數(shù) | 說(shuō)明 | 必填 | 說(shuō)明 | 最低版本 |
---|---|---|---|---|
filePath | String | 是 | 文件路徑,可通過(guò) downFile 獲得 | |
fileType | String | 否 | 文件類型,指定文件類型打開(kāi)文件,有效值 doc, xls, ppt, pdf, docx, xlsx, pptx | 1.4.0 |
success | Function | 否 | 接口調(diào)用成功的回調(diào)函數(shù) | |
fail | Function | 否 | 接口調(diào)用失敗的回調(diào)函數(shù) | |
complete | Function | 否 | 接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會(huì)執(zhí)行) |
示例代碼
wx.downloadFile({
url: 'http://example.com/somefile.pdf',
success: function (res) {
var filePath = res.tempFilePath
wx.openDocument({
filePath: filePath,
success: function (res) {
console.log('打開(kāi)文檔成功')
}
})
}
})
更多微信小程序開(kāi)發(fā)教程,可以關(guān)注hi小程序。
第二部分:如何開(kāi)通一個(gè)小商店
- 第 1 頁(yè)【微信小程序API文件】微信小程序API文件,wx.saveFile保存文件到本地
- 第 2 頁(yè)【wx.getfileinfo】 微信小程序獲取文件信息代碼wx.getfileinfo
- 第 3 頁(yè)【wx.getsavedfilelist】 wx.getsavedfilelist獲取本地已保存的小程序文件列表
- 第 4 頁(yè)【wx.removesavedfile】 wx.removesavedfile小程序怎么刪除本地存儲(chǔ)的文件
- 第 5 頁(yè)【wx.opendocument】 wx.opendocument微信小程序新開(kāi)頁(yè)面打開(kāi)文檔怎么做