微信小程序之打開文檔功能


/* 打開文檔
* @param fileUrl: 文件地址
* @param filetype: 文件類型
*/
openDocument(fileUrl, filetype) {
    wx.downloadFile({
        url: fileUrl,
        success: res => {
            const filePath = res.tempFilePath;
            wx.openDocument({
                 filePath: filePath,
                 fileType: filetype,
                 success: function (res) {
                    // console.log("打開文檔成功")
                 },
                 fail: function (res) {
                    wx.showToast({title: '打開文檔失敗', icon: 'none', duration: 2000})
                 },
            })
         },
         fail: res => {
             console.log(res);
         },
   });
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM