微信小程序之打开文档功能


/* 打开文档
* @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