dva子组件跳转页面三种方式

方式一.视图跳转 Link

import { Link } from "dva/router";
 render() {
    return (
      <>
        去首页
      
    );
  }

方式二.借助withRouter的history.push实现跳转

import { withRouter} from "dva/router";
class GoodList extends Component {
  goHome = () => {
    this.props.history.push("/");
  }
 render() {
    return (
      <>
        
去首页
); } } export default withRouter(GoodList);

方式三.借助routerRedux的routerRedux.push实现跳转

import {  routerRedux } from "dva/router";
goHome = () => {
    this.props.dispatch(routerRedux.push("/"));
  };
render() {
    return (
      <>
        
去首页
); }

你可能感兴趣的:(react,react.js)