uni-app開發小程序-使用uni.switchTab跳轉后頁面不刷新的問題


onload中如果接受傳參的話必須要傳入參數或則做無參數處理!

uni.showToast({
                                        title: "用戶取消付款!",
                                        icon: "none",
                                        success: () => {
                                            setTimeout(() => {
                                                
                                                uni.switchTab({
                                                    url: "../library/library?topIndex=1&subIndex=3",
                                                    success: (res) => {
                                                        console.log('跳轉成功',res)
                                                        let data={
                                                            topIndex:1,
                                                            subIndex:3
                                                        }
                                                        let page = getCurrentPages().pop();
                                                        if (page == undefined || page == null) return;
                                                        page.onLoad(data);
                                                    },
                                                    fail: (err) => {
                                                        console.log('跳轉失敗',err)
                                                    }
                                                })
                                            }, 1500);
                                        }
                                    })

switchTab成功跳轉后調用success,此時可以拿到跳轉后頁面的page對象,從而調用頁面onLoad方法重載頁面;微信后期應該會加相應的參數來決定是否刷新跳轉

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM