【已解决】React如何通过路由重新加载当前页面Warning: You cannot PUSH the same path using hash history

xiaoxiao2021-02-28  61

在当前页面点击按钮想重新加载却发现react不刷新当前页面,提示

  Warning: You cannot PUSH the same path using hash history

解决方法:只需要新建一个空白页面.先跳转到空白页面.再从空白页面跳转到当前页面即可

index.jsx页面执行:

     hashHistory.push({                pathname: '/blank',//空白页面                 //pathname: 'app/index',

         })

blank页面执行跳转:

componentWillMount(){    hashHistory.push({                pathname: 'app/index',//返回当前页面         })    }

          

转载请注明原文地址: https://www.6miu.com/read-2625829.html

最新回复(0)