react.js - react-route 中路由跳转?
本文介绍了react.js - react-route 中路由跳转?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
可能是我英语太差还是 api 太low。没找到怎么使用 命令式跳转。
https://reacttraining.com/rea...
报错:
browser.js?fec5:49 Warning: Hash history cannot PUSH the same path; a new entry will not be added to the history stack
import React from 'react';
import PropTypes from 'prop-types';
require("../style/back.less");
export default class yourClass extends React.Component {
constructor(props) {
console.log(props);
super(props);
this.state = {}
};
linkTap = () => {
console.log("tap");
this.props.history.push({
pathName: "/counter"
});
}
render = () => {
return (<div className="up-page page-back">
<div className="content" onClick={this.linkTap}>content link to counter</div>
</div>)
};
}
强烈推荐 学习vueJs。简洁优雅,官方文档更友好。
解决方案
我用的是route v4
这篇关于react.js - react-route 中路由跳转?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文