react点击事件路由跳转 react-router不用Link怎么跳转路由?

react-router不用Link怎么跳转路由?history.pushState的话确实只是在history里面添加一条路由记录,并且改变url,不会刷新页面,所以内容不会变,解决的办法可以用如下

react-router不用Link怎么跳转路由?

history.pushState

的话确实只是在history里面添加一条路由记录,并且改变url,不会刷新页面,所以内容不会变,解决的办法可以用如下代码试试:

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常见的路由和页面跳转api?

uni.navigateTo

保留当前页面,跳转到应用内的某个页面,使用uni.navigateBack可以返回到原页面。

uni.redirectTo(OBJECT)

关闭当前页面,跳转到应用内的某个页面

uni.reLaunch(OBJECT)

关闭所有页面,打开到应用内的某个页面。

uni.switchTab(OBJECT)

跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面。

uni.navigateBack(OBJECT)

关闭当前页面,返回上一页面或多级页面。可通过 getCurrentPages() 获取当前的页面栈,决定需要返回几层。