使用的 react-router 2.4.0
import { Link , History} from 'react-router';
//分页点击跳转
onChange (index) {
this.setState({ index });
let Id = this.state.Id;
this.props.history.pushState(null,'list/'+ Id +'/page/'+index);
}
以上是 在点击分页 组件的时候 做 路由跳转
但在浏览器控制台 报错了
browser.js:49Warning: [react-router] `props.history` and `context.history` are deprecated. Please use `context.router`. http://tiny.cc/router-contextchanges
请使用 context.router 这个该怎么用呢
查看官方的 警告地址
按着 文档上说的 使用 this.context.route
以下代码
this.context.route('list/'+ Id +'/page/'+index);
以上事件鼠标点击后 就报错了 , 因为 没有 this.context
这个 this.context 需要在哪定义好吗
求 React-router 大神指导一下 这个 js 路由跳转该如何破
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
认证高级PHP讲师