在actions中,定義了一個(gè)方法去調(diào)用接口,然后在頁(yè)面中調(diào)用actions中定義的方法,當(dāng)actions方法成功請(qǐng)求接口后,如何自動(dòng)跳轉(zhuǎn)到指定的path,在actions中寫過(guò)this.props.history.push(""),然后報(bào)history undefined,然后試過(guò)很多寫法,都不能達(dá)到效果,請(qǐng)大家?guī)蛶兔?,出出主意,非常感謝
1 回答

ibeautiful
TA貢獻(xiàn)1993條經(jīng)驗(yàn) 獲得超6個(gè)贊
先引入import { Link, withRouter } from "react-router-dom";
再包裝const Component = withRouter(createForm()(_Component));
這樣history就不會(huì)報(bào)undefined了
添加回答
舉報(bào)
0/150
提交
取消