【javascript – React.js – 简单的英语是什么mapDispatchToProps?】教程文章相关的互联网学习教程文章

夺命雷公狗-----React---9--map数据的遍历【代码】【图】

比如我们要实现的是这种效果:用这种方法来写,她只能写死在哪,没啥意思,所以我们定义一个数据,然后来测试下map方法对她遍历出来的数据 <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Document</title><script src="./js/react-with-addons.js"></script><script src="./js/react-dom.js"></script><script src="./js/browser.min.js"></script></head><body><div id="demo"></div><script type="text/ba...

javascript – React JS – Uncaught TypeError:this.props.data.map不是函数【代码】

我正在使用reactjs,并且在尝试显示json数据时(无论是来自文件还是服务器)似乎无法阻止此错误:Uncaught TypeError: this.props.data.map is not a function我看过: React code throwing “TypeError: this.props.data.map is not a function” React.js this.props.data.map() is not a function 这些都没有帮助我解决问题.我的页面加载后,我可以验证this.data.props没有未定义(并且有一个等价于json对象的值 – 可以使用window.f...

javascript-react获取数组的数据时遇到Cannotreadproperty&#039;map&#039;ofundefined

当我要提取listDate的时候,map提示undefined.打印listDate的时候显示其中有map的方法。这是为什么呢?代码很简单,就是react中文网的例子. 这是php的代码: { "status":0, "records":{"title": "Here's the book list","listData": [{"name": "沙滩搁浅我们的旧时光", "author": "XiaoMing"},{"name": "女人天生高贵", "author": "XiaoDong"},{"name": "海是彩色的灰尘", "author": "XiaoXi"}]} } 这是react代码回复内容:当我要提取...

javascript-ReactJS:this.props.data.map不是函数【代码】

我正在尝试从.json文件中获取数据,并通过视图显示结果.以下是scoreboard.json文件.{ "subject":"scoreboard", "copyright":"Copyright 2015", "data":"games":{"next_day_date":"2015-07-22","modified_date":"2015-08-04T07:34:50Z","month":"07","year":"2015","game":[{"game_type":"R","double_header_sw":"N","location":"Some City, State",}, {"game_type":"R","double_header_sw":"N","location":"Another City, Another S...

javascript-在react-google-map上动态添加标记【代码】

我不想要做的是在地图上显示从某些移动设备上选择的位置.有关位置的数据在那里. 我这里需要根据从服务器接收到的数据在地图上添加标记. 假设我已将位置数据({Lat,Lang})设置为状态标记然后,如何添加它以显示在地图中. 我的地图代码如下!import React, { Component } from 'react'; import GoogleMapReact from 'google-map-react';const AnyReactComponent = ({ text }) => <div>{text}</div>;class MyClass extends Component {c...

javascript-未捕获的TypeError:无法读取ReactJs中{Component} .render上未定义的属性“ map”【代码】

我正在将数组传递给侧边栏组件的道具,我想在我的子组件中访问它… 当我保存代码并转到浏览器时…我收到此错误消息import React, { Component } from 'react'; import PropTypes from 'prop-types';import './styles.scss';import Sidebar from './../../components/sidebar'; import Header from './../../components/header';export default class Dashboard extends Component {buildComponent = props => {console.log("Props",...

javascript – 在.map函数中使用react道具[复制]【代码】

参见英文答案 > How to access the correct `this` inside a callback? 10个假设我的一个组件上有以下渲染功能.从父元素我传递了一个changeTid prop函数. 家长:<RequestsList data={this.state.data} changeTid={this.changeTid} />儿童: (我正在使用ES6课程)render() { var RequestNodes = this.props.data.map(function(request) {return (<Request key={request.TID} changeTid={this.p...

javascript – React.js this.props.data.map()不是函数【代码】

我正在搞乱反应并试图解析并渲染一个json对象.现在,我只是设置一个硬编码的对象进行测试,而不是从ajax调用中获取它.<script type="text/jsx">var Person = React.createClass({ render: function() {return (<div><p className="personName"></p><p className="personSA1"></p><p className="personSA2"></p><p className="zip"></p><p className="state"></p><p className="country"></p></div>);} });var PersonDiv = React.crea...

javascript – React JS嵌套条件,.map()上的意外错误【代码】

我正在尝试渲染嵌套条件,一个案例会让我使用.map()renderClasses () {if (!this.state.classes.length) {console.log(this.state.userType)if (this.state.userType) return(<div>Add Class</div>)else return (<div>Join Class</div>)} else {return (<div>{this.state.classes.map((class) => {^ unexpected token here <div>one class</div>})}</div>)}}render() {if (!this.state.isLogged) {return <Redirect to='/' />}retur...

javascript – 如何在React Native Android中实现Google Map(React-Native-Maps)【代码】

我一直在使用https://github.com/lelandrichardson/react-native-maps/blob/master/docs/installation.md的React-Native-Maps库 我已经完成了所有的滴注步骤,但我仍然收到一个空白屏幕(整个反应屏幕都是白色的,就像没有渲染一样). 但是,当我尝试在反应中渲染元素时,会弹出文本.因此我的地图没有显示是我执行库而不是反应问题的结果. 这是我的index.android.js页面的代码/*** Sample React Native App* https://github.com/facebook...

javascript – 获取React渲染中map返回的数组大小【代码】

我在React组件的render方法中使用了array.map.它可以工作,但我想知道它渲染了多少行.我正在尝试在我的构造函数中初始化this.numRows = 0,然后在map回调中递增它:<div><p>Number of rows = {this.numRows}</p>{this.state.members.map((member) => {if (member.display) {this.numRows++;return <p>{ member.name }</p> }})}</div>但这仍然显示为零.完整代码:jsfiddle.net/ra13jxak/.如何显示返回的行数?解决方法:您可以考虑先过...

javascript – 使用react-bootstrap中的map正确渲染多个模态【代码】

我试图用地图渲染多个react-bootsrap模态,但我无法这样做.使用我当前的代码,单击“查看详细信息”按钮可同时激活所有模态,而不是打开相关模态.这是我的代码与模态相关的片段:render() {const { accounts } = this.props;const displayAccounts = Object.keys(accounts).filter(key => {return accounts[key].info.type === 'student'}).map(key => {return (<tr key={key}><th>{accounts[key].info.name}</th><td>{accounts[key]....

javascript – map函数中的if else语句reactjs【代码】

您不必阅读整个代码,只需阅读editQuantity函数和showOrderItem函数中的注释,特别是在showOrderItem函数中,我的问题是我认为只是愚蠢,因为我的两个函数都在工作,因为它们应该工作, * editQuantity函数应该改变状态,它改变它,我通过添加控制台行检查. * showOrderItem函数假设显示项目,他也在做这个工作. 我的问题是,我尝试在showOrderItem函数中添加不起作用的条件渲染,即使我能够改变状态. 请阅读showOrderItem函数中的注释,以查看...

javascript – React .map()不是函数错误【代码】

import React, {Component} from 'react'; import './App.css'; import axios from 'axios';export default class App extends Component {constructor() {super();this.state = {weather: []};} componentDidMount (){this.search(); }search = () => {axios.get("http://api.openweathermap.org/data/2.5/weather?q=Houston&APPID=f2327cca8f3d665f4c9f73b615b294ed").then(res => {this.setState({weather: res.data});}).catch...