雨悸
雨悸
  • 发布:2020-11-02 09:33
  • 更新:2020-11-03 15:55
  • 阅读:1646

plus.runtime.arguments=''和plus.runtime.arguments=null无法清空plus.runtime.arguments

分类:uni-app

plus.runtime.arguments无法清空。
plus.runtime.arguments=''和plus.runtime.arguments=null 不管用 怎么清空?

2020-11-02 09:33 负责人:无 分享
已邀请:
雨悸

雨悸 (作者)

解决方案:

我刚开始是app onshow里面写,想着APP在后台运行被唤醒也能取到,但是出现的问题是无法清除。

后面改为在app onLaunch里面写:

        this.checkArguments(); // 检测启动参数  
        // 重点是以下: 一定要监听后台恢复 !一定要  
        plus.globalEvent.addEventListener('newintent', (e)=>{  
            this.checkArguments(); // 检测启动参数  
        });  
        // #endif  

methods: {  
        checkArguments() {  
            console.log('runtime.launcher: ' + plus.runtime.launcher);  
            try {  
                    var args = plus.runtime.arguments;  
                    console.log(args);  
                    if (args) {  
                        let url = args.substring(args.indexOf('?path=') + 6, args.length);  
                        url = unescape(url) || '';  
                        console.log(url);  
                        // 处理args参数,如直达到某新页面等  
                        this.openPage({  
                            url:url  
                        });  
                    }  
                } catch (e) {  
                    console.log('exception: ' + e);  
            }  

        }  
}

该问题目前已经被锁定, 无法添加新回复