作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试修改react-router-redux的示例代码。 https://github.com/rackt/react-router-redux/blob/master/examples/basic/components/Home.js
这是我的 Home.js
class Home extends Component {
onSubmit(props) {
this.props.routeActions.push('/foo');
}
}
我还有一个mapDispatchToProps。
function mapDispatchToProps(dispatch){
return bindActionCreators({ routeActions },dispatch);
}
当我调用 onSubmit 函数时,出现错误
Uncaught TypeError: this.props.routeActions.push is not a function
如果我在 onSubmit 中删除 this.props,URL 中的键会发生变化,但它仍然在同一页面上。来自 localhost:8080/#/?_k=iwio19
至localhost:8080/#/?_k=ldn1ew
有人知道怎么解决吗?欣赏它。
最佳答案
我不认为 routeActions
是作为 props
传递的。你想做的是这样的:
import { routeActions } from 'react-router-redux'
this.props.dispatch(routeActions.push('/foo'));
关于reactjs - 如何使用react-router-redux的routeActions?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35196873/
这个问题已经有答案了: Swift Instance member cannot be used on type (2 个回答) 已关闭 6 年前。 我在类中声明了属性: class RouteAct
当我在 laravel 5.4 中创建 Controller 时出现此错误 In RouteAction.php line 84: Invalid route action: [App\Http\Co
我是一名优秀的程序员,十分优秀!