router
若您有跨端需求,您可以使用 router 对象实现您的路由跳转。
router.push(url: string)
router.replace(url: string) // 参数获取同push
router.back()
router.go(delta: number)
router.reload()
引入
import { router } from '@ray-js/ray';
使用
/// routers.config.ts
import { Routes } from '@ray-js/types';
export const routes: Routes = [
{
route: '/',
path: '/pages/home/index',
},
{
route: '/detail/:uid',
path: '/pages/detail/index',
},
{
route: '/my',
path: '/pages/my/index',
},
];
push
router.push(url: string)
hash 参数
router.push('/detail/1234')
detail 页面的路由配置为 /detail/:uid
,您可以在 detail
页面的 props.location.query.uid
获取 uid
。
query 参数
router.push('/detail/1234?name=tuya')
您可以在 detail
页面的 props.location.query.name
获取 query
参数 name
。
此页内容是否对您有帮助?
是
意见反馈