方式一.视图跳转 Link
import { Link } from "dva/router";
render() {
return (
<>
<Link to="/">去首页</Link>
</>
);
}
方式二.借助withRouter的history.push实现跳转
import { withRouter} from "dva/router";
class GoodList extends Component {
goHome = () => {
this.props.history.push("/");
}
render() {
return (
<>
<div onClick={this.goHome}>去首页</div >
</>
);
}
}
export default withRouter(GoodList);
方式三.借助routerRedux的routerRedux.push实现跳转
import { routerRedux } from "dva/router";
goHome = () => {
this.props.dispatch(routerRedux.push("/"));
};
render() {
return (
<>
<div onClick={this.goHome}>去首页</div >
</>
);
}