uni-app中,封装的查看文件的方法

uni-app中,封装的查看文件的方法,记录内容

lookFiles(url) {
    
    
        uni.downloadFile({
    
    
            url: url,
            success: function (res) {
    
    
                var filePath = res.tempFilePath;
                uni.openDocument({
    
    
                    filePath: filePath,
                    fail: (e) => {
    
    
                        uni.showToast({
    
    
                            title: '预览文件失败',
                            icon: 'error',
                        });
                    },
                });
            },
            fail: function(err) {
    
     
                uni.showToast({
    
    
                    title: '预览文件失败',
                    icon: 'error',
                });
            },
        });
    };

猜你喜欢

转载自blog.csdn.net/weixin_44244230/article/details/124629269
今日推荐