react點擊事件路由跳轉(zhuǎn) react-router不用Link怎么跳轉(zhuǎn)路由?
react-router不用Link怎么跳轉(zhuǎn)路由?history.pushState的話確實只是在history里面添加一條路由記錄,并且改變url,不會刷新頁面,所以內(nèi)容不會變,解決的辦法可以用如下
react-router不用Link怎么跳轉(zhuǎn)路由?
history.pushState
的話確實只是在history里面添加一條路由記錄,并且改變url,不會刷新頁面,所以內(nèi)容不會變,解決的辦法可以用如下代碼試試:class Test {
constructor(props, context){
super(props, context)
this.router
= context.router}
}
Test.contextTypes
= {router:
PropTypes.object.isRequired
}
在你ui組件的onChange事件里面寫如下代碼:
this.router.push(...)
uni-app常見的路由和頁面跳轉(zhuǎn)api?
uni.navigateTo
保留當(dāng)前頁面,跳轉(zhuǎn)到應(yīng)用內(nèi)的某個頁面,使用uni.navigateBack可以返回到原頁面。
uni.redirectTo(OBJECT)
關(guān)閉當(dāng)前頁面,跳轉(zhuǎn)到應(yīng)用內(nèi)的某個頁面
uni.reLaunch(OBJECT)
關(guān)閉所有頁面,打開到應(yīng)用內(nèi)的某個頁面。
uni.switchTab(OBJECT)
跳轉(zhuǎn)到 tabBar 頁面,并關(guān)閉其他所有非 tabBar 頁面。
uni.navigateBack(OBJECT)
關(guān)閉當(dāng)前頁面,返回上一頁面或多級頁面??赏ㄟ^ getCurrentPages() 獲取當(dāng)前的頁面棧,決定需要返回幾層。