javascript - Reactjs關於函數內跳轉 this.context.router.push(path)的問題
PHP中文网
PHP中文网 2017-07-05 11:04:52
0
3
950

請教各位師兄了。
我建立了一個元件Component,並在內部中的一個ajax成功回調內,寫了this.context.router.push("/user/list")類似的跳轉功能。同時在元件外寫了Component.contextTypes={ router: React.PropTypes.object.isRequired }。 ajax也成功要求了,但是頁面並沒有跳轉,有點疑問了。 。 。
程式碼結構類似:

class Component extends React.Component{
    ...
    success: function(data) {
        alert(data);
        this.context.router.push(...)
    }
}
Component.contextTypes={
    router: React.PropTypes.object.isRequired
}
PHP中文网
PHP中文网

认证0级讲师

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!