uniapp 小程序 安卓 ios 通用监听路由跳转方法

async watchRouter(callback) {
            let that = this;
            //#ifdef APP-PLUS
            let RouterTypes = ['navigateTo', 'redirectTo', 'switchTab', 'navigateBack', 'reLaunch'];
            RouterTypes.forEach(item => {
                uni.addInterceptor(item, {
                    invoke(e) {
                        callback(); 
                    },
                    returnValue(e) {}
                });
            })
            // #endif
            //#ifdef MP-WEIXIN
            wx.onAppRoute(page => {
                let that = this;
                console.log(`%c 全局路由监听中==>${page.path}`, 'color:green;font-size:30px;');
                callback() 
            });
            //#endif    
        },

你可能感兴趣的:(uni-app,小程序,android)