x***@163.com
x***@163.com
  • 发布:2022-08-04 15:17
  • 更新:2023-01-06 16:06
  • 阅读:582

求助,plus.runtime.openURL打不开网址

分类:uni-app
        var url = "https://m.toutiao.com/is/2TQBxfj/?"  
    var _this=this  
    uni.showModal({  
            title: '打开链接?',  
            content: '即将打开链接:'+url,  
            success: function(res) {  
                if (res.confirm) {    
                //#ifdef APP-PLUS  
                    plus.runtime.openURL(url, err=>{  
                        console.log(err)  
                        console.log("打开失败")  
                        if ( plus.os.name == "Android" ) {  
                            plus.runtime.launchApplication( {pname:"com.android.browser"  
                            ,extra:{url:url}}, function ( e ) {  
                                console.log( e );  
                            } );  
                        } else if ( plus.os.name == "iOS" ) {  
                            plus.runtime.launchApplication( {action:url}, function ( e ) {  
                                console.log( e );  
                                } );  
                            }  
                        });  
                //#endif  
                }  
            }  
    });

报错:

去掉链接最后的 '?' 就可以打开了

2022-08-04 15:17 负责人:无 分享
已邀请:
FullStack

FullStack - 【插件开发】【专治疑难杂症】【ios上架、马甲包、白包、过审、已成功上架过几百个】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=22130】【非诚勿扰】QQ:543610866

ios可以,能打开不就行啦,不纠结

x***@163.com

x***@163.com (作者)

记录一下:url要用trim()去除两端空格,否则在Android平台打开会报错

要回复问题请先登录注册