- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从这个对象数组中提取“主要”数据。我对此还很陌生,所以任何建议都会有所帮助。
import React, { Component } from 'react';
class CurrentLocation extends Component {
loopThroughKeys(obj) {
return obj.forEach(function(obj) {
return Object.keys(obj).map(function() {
let main = obj.main;
return Object.keys(main).map(function(key) {
let type = key;
let value = main[key];
console.log(type, value);
return (
<li>
<span key={key}>
{type}:{value}
</span>
</li>
);
});
});
});
}
render() {
let weather = this.props.weather;
console.log(this.props.weather);
if (!weather.list) {
return <div>Loading...</div>;
}
return (
<div className="currentWeather">
<h1>hi</h1>
<div className="container">
<ul className="card">{this.loopThroughKeys(weather.list)}</ul>
</div>
</div>
);
}
}
export default CurrentLocation;
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
import React, { Component } from 'react';
class CurrentLocation extends Component {
loopThroughKeys(obj) {
return obj.forEach(function(obj) {
return Object.keys(obj).map(function() {
let main = obj.main;
return Object.keys(main).map(function(key) {
let type = key;
let value = main[key];
console.log(type, value);
return (
<li>
<span key={key}>
{type}:{value}
</span>
</li>
);
});
});
});
}
render() {
let weather = this.props.weather;
console.log(this.props.weather);
if (!weather.list) {
return <div>Loading...</div>;
}
return (
<div className="currentWeather">
<h1>hi</h1>
<div className="container">
<ul className="card">{this.loopThroughKeys(weather.list)}</ul>
</div>
</div>
);
}
}
export default CurrentLocation;
var weather.list={
cod: "200",
message: 0.0082,
cnt: 40,
list: [
{
dt: 1485799200,
main: {
temp: 283.76,
temp_min: 283.76,
temp_max: 283.761,
pressure: 1017.24,
sea_level: 1026.83,
grnd_level: 1017.24,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 7.27,
deg: 15.0048
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-01-30 18:00:00"
},
{
dt: 1485810000,
main: {
temp: 282.56,
temp_min: 282.56,
temp_max: 282.563,
pressure: 1020.06,
sea_level: 1029.63,
grnd_level: 1020.06,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 6.21,
deg: 31.5035
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-01-30 21:00:00"
},
{
dt: 1485820800,
main: {
temp: 282.3,
temp_min: 282.296,
temp_max: 282.3,
pressure: 1022.71,
sea_level: 1032.27,
grnd_level: 1022.71,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01d"
}
],
clouds: {
all: 0
},
wind: {
speed: 6.71,
deg: 51.0002
},
rain: { },
sys: {
pod: "d"
},
dt_txt: "2017-01-31 00:00:00"
},
{
dt: 1485831600,
main: {
temp: 282.27,
temp_min: 282.265,
temp_max: 282.27,
pressure: 1023.68,
sea_level: 1033.16,
grnd_level: 1023.68,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01d"
}
],
clouds: {
all: 0
},
wind: {
speed: 5.46,
deg: 65.5
},
rain: { },
sys: {
pod: "d"
},
dt_txt: "2017-01-31 03:00:00"
},
{
dt: 1485842400,
main: {
temp: 282.656,
temp_min: 282.656,
temp_max: 282.656,
pressure: 1023.75,
sea_level: 1033.22,
grnd_level: 1023.75,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01d"
}
],
clouds: {
all: 0
},
wind: {
speed: 4.11,
deg: 84.0055
},
rain: { },
sys: {
pod: "d"
},
dt_txt: "2017-01-31 06:00:00"
},
{
dt: 1485853200,
main: {
temp: 282.783,
temp_min: 282.783,
temp_max: 282.783,
pressure: 1024.91,
sea_level: 1034.46,
grnd_level: 1024.91,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 3.6,
deg: 89.0062
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-01-31 09:00:00"
},
{
dt: 1485864000,
main: {
temp: 283.335,
temp_min: 283.335,
temp_max: 283.335,
pressure: 1025.21,
sea_level: 1034.83,
grnd_level: 1025.21,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 803,
main: "Clouds",
description: "broken clouds",
icon: "04n"
}
],
clouds: {
all: 68
},
wind: {
speed: 3.37,
deg: 115
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-01-31 12:00:00"
},
{
dt: 1485874800,
main: {
temp: 284.657,
temp_min: 284.657,
temp_max: 284.657,
pressure: 1023.65,
sea_level: 1033.43,
grnd_level: 1023.65,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 802,
main: "Clouds",
description: "scattered clouds",
icon: "03n"
}
],
clouds: {
all: 36
},
wind: {
speed: 3.32,
deg: 177.501
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-01-31 15:00:00"
},
{
dt: 1485885600,
main: {
temp: 284.095,
temp_min: 284.095,
temp_max: 284.095,
pressure: 1022.05,
sea_level: 1031.79,
grnd_level: 1022.05,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "02n"
}
],
clouds: {
all: 8
},
wind: {
speed: 4.26,
deg: 254.003
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-01-31 18:00:00"
},
{
dt: 1485896400,
main: {
temp: 283.211,
temp_min: 283.211,
temp_max: 283.211,
pressure: 1021.33,
sea_level: 1031.06,
grnd_level: 1021.33,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 4.32,
deg: 271.5
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-01-31 21:00:00"
},
{
dt: 1485907200,
main: {
temp: 284.179,
temp_min: 284.179,
temp_max: 284.179,
pressure: 1020.57,
sea_level: 1030.28,
grnd_level: 1020.57,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 801,
main: "Clouds",
description: "few clouds",
icon: "02d"
}
],
clouds: {
all: 20
},
wind: {
speed: 10.16,
deg: 256.504
},
rain: { },
sys: {
pod: "d"
},
dt_txt: "2017-02-01 00:00:00"
},
{
dt: 1485918000,
main: {
temp: 284.829,
temp_min: 284.829,
temp_max: 284.829,
pressure: 1017.39,
sea_level: 1027.23,
grnd_level: 1017.39,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "02d"
}
],
clouds: {
all: 8
},
wind: {
speed: 13.76,
deg: 259.502
},
rain: { },
sys: {
pod: "d"
},
dt_txt: "2017-02-01 03:00:00"
},
{
dt: 1485928800,
main: {
temp: 285.702,
temp_min: 285.702,
temp_max: 285.702,
pressure: 1014.64,
sea_level: 1024.23,
grnd_level: 1014.64,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 801,
main: "Clouds",
description: "few clouds",
icon: "02d"
}
],
clouds: {
all: 12
},
wind: {
speed: 12.75,
deg: 264.001
},
rain: { },
sys: {
pod: "d"
},
dt_txt: "2017-02-01 06:00:00"
},
{
dt: 1485939600,
main: {
temp: 285.494,
temp_min: 285.494,
temp_max: 285.494,
pressure: 1014.1,
sea_level: 1023.71,
grnd_level: 1014.1,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 12.33,
deg: 271.5
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-02-01 09:00:00"
},
{
dt: 1485950400,
main: {
temp: 285.16,
temp_min: 285.16,
temp_max: 285.16,
pressure: 1014.54,
sea_level: 1024.27,
grnd_level: 1014.54,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 12.21,
deg: 278.504
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-02-01 12:00:00"
},
{
dt: 1485961200,
main: {
temp: 284.161,
temp_min: 284.161,
temp_max: 284.161,
pressure: 1016.13,
sea_level: 1025.81,
grnd_level: 1016.13,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 12.21,
deg: 281
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-02-01 15:00:00"
},
{
dt: 1485972000,
main: {
temp: 282.63,
temp_min: 282.63,
temp_max: 282.63,
pressure: 1017.33,
sea_level: 1027,
grnd_level: 1017.33,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 9.3,
deg: 297.001
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-02-01 18:00:00"
},
{
dt: 1485982800,
main: {
temp: 281.856,
temp_min: 281.856,
temp_max: 281.856,
pressure: 1018.51,
sea_level: 1028.24,
grnd_level: 1018.51,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 8.91,
deg: 288
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-02-01 21:00:00"
},
{
dt: 1485993600,
main: {
temp: 281.978,
temp_min: 281.978,
temp_max: 281.978,
pressure: 1019.22,
sea_level: 1028.89,
grnd_level: 1019.22,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01d"
}
],
clouds: {
all: 0
},
wind: {
speed: 9.15,
deg: 286.504
},
rain: { },
sys: {
pod: "d"
},
dt_txt: "2017-02-02 00:00:00"
},
{
dt: 1486004400,
main: {
temp: 283.706,
temp_min: 283.706,
temp_max: 283.706,
pressure: 1017.36,
sea_level: 1026.99,
grnd_level: 1017.36,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01d"
}
],
clouds: {
all: 0
},
wind: {
speed: 8.95,
deg: 288.003
},
rain: { },
sys: {
pod: "d"
},
dt_txt: "2017-02-02 03:00:00"
},
{
dt: 1486015200,
main: {
temp: 285.125,
temp_min: 285.125,
temp_max: 285.125,
pressure: 1016.41,
sea_level: 1026.05,
grnd_level: 1016.41,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01d"
}
],
clouds: {
all: 0
},
wind: {
speed: 7.56,
deg: 294.002
},
rain: { },
sys: {
pod: "d"
},
dt_txt: "2017-02-02 06:00:00"
},
{
dt: 1486026000,
main: {
temp: 284.755,
temp_min: 284.755,
temp_max: 284.755,
pressure: 1018.18,
sea_level: 1027.75,
grnd_level: 1018.18,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 8.31,
deg: 290.504
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-02-02 09:00:00"
},
{
dt: 1486036800,
main: {
temp: 283.765,
temp_min: 283.765,
temp_max: 283.765,
pressure: 1019.04,
sea_level: 1028.51,
grnd_level: 1019.04,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 8.87,
deg: 283.001
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-02-02 12:00:00"
},
{
dt: 1486047600,
main: {
temp: 283.809,
temp_min: 283.809,
temp_max: 283.809,
pressure: 1018.6,
sea_level: 1028.26,
grnd_level: 1018.6,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 8.73,
deg: 281.001
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-02-02 15:00:00"
},
{
dt: 1486058400,
main: {
temp: 283.788,
temp_min: 283.788,
temp_max: 283.788,
pressure: 1018.68,
sea_level: 1028.33,
grnd_level: 1018.68,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 7.8,
deg: 281.503
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-02-02 18:00:00"
},
{
dt: 1486069200,
main: {
temp: 283.569,
temp_min: 283.569,
temp_max: 283.569,
pressure: 1019.28,
sea_level: 1028.92,
grnd_level: 1019.28,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 5.92,
deg: 284.002
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-02-02 21:00:00"
},
{
dt: 1486080000,
main: {
temp: 284.11,
temp_min: 284.11,
temp_max: 284.11,
pressure: 1020.75,
sea_level: 1030.35,
grnd_level: 1020.75,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01d"
}
],
clouds: {
all: 0
},
wind: {
speed: 1.83,
deg: 284.506
},
rain: { },
sys: {
pod: "d"
},
dt_txt: "2017-02-03 00:00:00"
},
{
dt: 1486090800,
main: {
temp: 285.034,
temp_min: 285.034,
temp_max: 285.034,
pressure: 1020.08,
sea_level: 1029.7,
grnd_level: 1020.08,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01d"
}
],
clouds: {
all: 0
},
wind: {
speed: 1.01,
deg: 172.002
},
rain: { },
sys: {
pod: "d"
},
dt_txt: "2017-02-03 03:00:00"
},
{
dt: 1486101600,
main: {
temp: 286.158,
temp_min: 286.158,
temp_max: 286.158,
pressure: 1018.77,
sea_level: 1028.39,
grnd_level: 1018.77,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01d"
}
],
clouds: {
all: 0
},
wind: {
speed: 0.71,
deg: 181.009
},
rain: { },
sys: {
pod: "d"
},
dt_txt: "2017-02-03 06:00:00"
},
{
dt: 1486112400,
main: {
temp: 286.138,
temp_min: 286.138,
temp_max: 286.138,
pressure: 1019.17,
sea_level: 1028.73,
grnd_level: 1019.17,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 1.51,
deg: 85.0026
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-02-03 09:00:00"
},
{
dt: 1486123200,
main: {
temp: 285.952,
temp_min: 285.952,
temp_max: 285.952,
pressure: 1019.74,
sea_level: 1029.36,
grnd_level: 1019.74,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 3.68,
deg: 76.5032
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-02-03 12:00:00"
},
{
dt: 1486134000,
main: {
temp: 285.828,
temp_min: 285.828,
temp_max: 285.828,
pressure: 1019.23,
sea_level: 1029.02,
grnd_level: 1019.23,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 3.36,
deg: 98.0014
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-02-03 15:00:00"
},
{
dt: 1486144800,
main: {
temp: 285.168,
temp_min: 285.168,
temp_max: 285.168,
pressure: 1018.15,
sea_level: 1027.96,
grnd_level: 1018.15,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 1.66,
deg: 333.002
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-02-03 18:00:00"
},
{
dt: 1486155600,
main: {
temp: 283.818,
temp_min: 283.818,
temp_max: 283.818,
pressure: 1018.65,
sea_level: 1028.36,
grnd_level: 1018.65,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01n"
}
],
clouds: {
all: 0
},
wind: {
speed: 3.77,
deg: 359.001
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-02-03 21:00:00"
},
{
dt: 1486166400,
main: {
temp: 283.157,
temp_min: 283.157,
temp_max: 283.157,
pressure: 1019.84,
sea_level: 1029.41,
grnd_level: 1019.84,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01d"
}
],
clouds: {
all: 0
},
wind: {
speed: 2.91,
deg: 18.5013
},
rain: { },
sys: {
pod: "d"
},
dt_txt: "2017-02-04 00:00:00"
},
{
dt: 1486177200,
main: {
temp: 283.494,
temp_min: 283.494,
temp_max: 283.494,
pressure: 1018.56,
sea_level: 1028.13,
grnd_level: 1018.56,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01d"
}
],
clouds: {
all: 0
},
wind: {
speed: 0.22,
deg: 280.501
},
rain: { },
sys: {
pod: "d"
},
dt_txt: "2017-02-04 03:00:00"
},
{
dt: 1486188000,
main: {
temp: 285.263,
temp_min: 285.263,
temp_max: 285.263,
pressure: 1016.77,
sea_level: 1026.41,
grnd_level: 1016.77,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01d"
}
],
clouds: {
all: 0
},
wind: {
speed: 1.88,
deg: 273.501
},
rain: { },
sys: {
pod: "d"
},
dt_txt: "2017-02-04 06:00:00"
},
{
dt: 1486198800,
main: {
temp: 285.927,
temp_min: 285.927,
temp_max: 285.927,
pressure: 1017.03,
sea_level: 1026.52,
grnd_level: 1017.03,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 801,
main: "Clouds",
description: "few clouds",
icon: "02n"
}
],
clouds: {
all: 12
},
wind: {
speed: 3.02,
deg: 269.505
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-02-04 09:00:00"
},
{
dt: 1486209600,
main: {
temp: 285.906,
temp_min: 285.906,
temp_max: 285.906,
pressure: 1016.93,
sea_level: 1026.64,
grnd_level: 1016.93,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 802,
main: "Clouds",
description: "scattered clouds",
icon: "03n"
}
],
clouds: {
all: 44
},
wind: {
speed: 3.77,
deg: 261.501
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-02-04 12:00:00"
},
{
dt: 1486220400,
main: {
temp: 285.51,
temp_min: 285.51,
temp_max: 285.51,
pressure: 1016.46,
sea_level: 1026.16,
grnd_level: 1016.46,
humidity: 100,
temp_kf: 0
},
weather: [
{
id: 802,
main: "Clouds",
description: "scattered clouds",
icon: "03n"
}
],
clouds: {
all: 44
},
wind: {
speed: 2.97,
deg: 283.001
},
rain: { },
sys: {
pod: "n"
},
dt_txt: "2017-02-04 15:00:00"
}
],
city: {
id: 1907296,
name: "Tawarano",
coord: {
lat: 35.0164,
lon: 139.0077
},
country: "none"
}
}
最佳答案
而不是 obj.forEach
,您需要使用map
为了返回自 forEach
以来的结果不返回任何内容
import React, { Component } from 'react';
class CurrentLocation extends Component {
loopThroughKeys(obj) {
return obj.map(function(obj) {
return Object.keys(obj).map(function() {
let main = obj.main;
return Object.keys(main).map(function(key) {
let type = key;
let value = main[key];
console.log(type, value);
return (
<li>
<span key={key}>
{type}:{value}
</span>
</li>
);
});
});
});
}
render() {
let weather = this.props.weather;
console.log(this.props.weather);
if (!weather.list) {
return <div>Loading...</div>;
}
return (
<div className="currentWeather">
<h1>hi</h1>
<div className="container">
<ul className="card">{this.loopThroughKeys(weather.list)}</ul>
</div>
</div>
);
}
}
export default CurrentLocation;
关于javascript - 迭代对象内的数组,console.log 工作,但我无法让它返回 react 元素。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52810894/
在开发中的网页上,我在 IE 上遇到此错误 element = $(element); 此代码位于prototype.js 预期对象 如何消除此错误。 更新: 现场也使用了 jQuery。 最佳答
我有两个大小相同的嵌套数组: Array1 =[[1, 2], [], [2, 3]] Array2= [[1, 4], [8, 11], [3, 6]] 我需要将它们合并到一个数组中,如下所示: A
我有一些 jQuery 代码,当单击具有特定 ID 的项目时运行。当 ID 是 的一部分时,它就可以工作。元素,但当它位于 中时则不然元素。为什么会这样呢?我想使用 an,因为如果用户关闭了 Ja
Flex-box 规范 3声明 flex 元素不是 block 容器: A flex item establishes a new formatting context for its content
我遇到了一个意想不到的问题。 HTML JS $(function() { var $divs = $('.myDiv'); // create new div not in
我使用 Bootstrap 和 Ember.js 得到了一个无序列表。每个列表项都是一个显示新帖子的链接,每当您单击该链接时,Ember 都会添加类 active默认情况下。我正在使用 Bootstr
我正在尝试让一个函数正常工作,但运气不佳,所以我想向 Stackoverflow 智囊团提出一个新手问题! 基本上,我有一个表单,并且循环遍历所有元素以查看是否存在自定义数据属性。如果存在,则保持该元
我想映射一个可选数组,删除那些 nil 值,并使用另一个函数映射非 nil 值。 我知道我可以通过使用 compactMap 然后使用常规 map 来实现这一点,但我只想遍历数组一次。 我为此实现了一
我如何定位 li 元素,除非它们出现在 之后元素?换句话说,我想针对步骤而不是注释。 我尝试向 OL 添加一个我想从选择中排除的类,但我想出的代码不起作用。 (顺便说一句,重构 html 不是一种选
Warning 1 The element 'system.webServer' has invalid child element 'rewrite'. List of possible eleme
我正在尝试编写一个脚本,该脚本将遍历 HTML 源并创建 DOM 的 JSON 文件,然后使用 d3.js 在 TreeView 中显示该文件。我遇到的问题是不仅希望显示元素(TITLE、P、LI 等
我有以下 HTML 表单:- Option 1 Option 2
我试图在选定的 HTML 元素之后选择下一个具有类名 slider-value 的 span 元素。我尝试了多种解决方案,但没有一个有效。 我可以通过 id 选择它,但我不希望那样做使代码冗余。 $(
如果电子邮件地址无效,我想在屏幕上显示一条消息“请输入有效的电子邮件地址”。 body 元素的innerHTML 语句工作正常,但我用于p 元素的innerHTML 语句不起作用。 有一次,当我测试它
以下 jQuery 代码调用 ul 元素,查找元素内的前 三个 li 列表项,并隐藏剩余的 li 项目。然后,它附加一个 li 元素,其中显示“显示更多...”,并且在单击时显示之前隐藏的列表项。 (
我问了a question早些时候关于将编辑/删除链接与 h1 元素内联的最佳方法。我能够通过给出的答案实现这一点,但我现在有额外的要求,我需要在 h1 下方显示一个段落并编辑/删除链接。 到目前为止
我使用 MVC 4 和 knockout.js 库版本 2.1.0 显示从服务器检索到的大量文件的表中的以下摘录。 0)"> 正在正确检索数据,
我创建了一个脚本,该脚本在鼠标悬停在父容器上时激活,并且应该将其子元素移离鼠标。我目前已经让它工作了,但是代码的某些部分似乎与 REACT 代码应该是什么样子相矛盾。特别是两个部分。 我在渲染函数中使
我是 JS 新手,正在尝试理解项目 https://github.com/tastejs/todomvc 的代码 请参阅屏幕截图,我尝试对 button X 以及其父元素 div 设置断点,但在这两种
例如,假设有一个带有奇特颜色的标记: Something written here 使用 Visual Studio 2017 和 MVC 5 元素,有没有办法检查和定位当前应用了哪些样式,以及负责它
我是一名优秀的程序员,十分优秀!