- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我遇到了范围界定问题。我可以从构造函数中 console.log this.props.routeParams.key 。但是,当在构造函数之外的 filterList 函数内时,我收到错误“Uncaught TypeError:无法读取未定义的属性“props””。我的范围界定问题是什么?为什么它可以从构造函数中读取 this 而不能从 filterList 函数中读取?
我正在使用 React Router + Flux + React。
import AltContainer from 'alt-container';
import React from 'react';
import { Link } from 'react-router';
import Blogger from './Blogger'
import List from './List'
const rootURL = 'https://incandescent-fire-6143.firebaseio.com/';
import BlogStore from '../stores/BlogStore'
import BlogActions from '../actions/BlogActions';
export default class BlogShow extends React.Component {
constructor(props) {
super(props);
{console.log(this.props.routeParams.key)}
}
filterList(key) {
if (this.props.routeParams.key===key){
return Blogstore.state.blog
}
}
render() {
{Object.keys(BlogStore.state.blog).map(this.filterList)}
}
}
最佳答案
发生这种情况是因为您的 filterList 函数未绑定(bind)到您的组件
将其绑定(bind)到构造函数中
constructor(props) {
super(props);
this.filterList = this.filterList.bind(this);
}
您读到过here
关于reactjs - React + React Router 中的范围界定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36967825/
我是 python 和 django 的新手,所以这个问题可能很容易解决,但我无法让它工作。基本上我有一个模型,其中包含两个用户类型的外键。我正在构建一个表单,我想在其中删除基于另一个字段的 Mode
很高兴从签名中知道(至少在 Safe Haskell 中)某些东西是否执行 IO 操作,但 IO 包含很多不同的东西 - putStr、数据库访问、删除和写入文件、IORef 等。 如果我在运行任意代
我有一个太大的强制有向图,因此我试图限制它。 下面是一些海量的JSON数据 var IDData = JSON.stringify([ ["1000000000039214051", "10000
这是我的 CoffeeScript : jQuery -> $("form").submit (e) -> e.preventDefault() email = $("#email
我是一名优秀的程序员,十分优秀!