When uniapp uni.openDocument use to open the file, open the success of Android, iOS open failed [reason: open the file name of the file is Chinese]

Solution: Use the escape for file name encoding

uni.downloadFile ({ 
                    URL: URL, 
                    Success: function (RES) { 
                        var filePath = res.tempFilePath;
                         // open file RMS DOC, XLS, PPT, PDF, docx, XLSX, PPTX 
                        uni.openDocument ({ 
                            filePath: Escape (filePath), 
                            Success: function (RES) { 
                                uni.hideLoading (); 
                                that.downloadFile_onoff = to true ; 
                            }, 
                            Fail () { 
                                uni.showToast({
                                    title: ' does not support this type ' , 
                                    DURATION: 2000 
                                }); 
                                uni.hideLoading (); 
                                that.downloadFile_onoff = to true ; 
                            } 
                        }); 
                        
                        
                        
                    } 
                });

 

Guess you like

Origin www.cnblogs.com/lizhao123/p/11498948.html