试图遍历道具在其他组件上传递的状态
state = {
question:[firstQ, secondQ, thirdQ],
tag:[[1,2,3],[4,6],[a,b,c,d]]
}
我想用Patter在下一个Componet上渲染它,
FirstQ
[tag1]
SecondQ
[tag2]
ThirdQ
[tag3]
等 我尝试了很多选择,但总是得到类似的东西
FirstQ
SecondQ
ThirdQ
[tag1]
[tag2]
[tag3]
编辑:
将数据传递到第二个组件
question={this.state.question}
tag={this.state.tag}
EDIT2:
现在我做了这样的循环
{this.props.question.map((item,) => {
return (<span key={item}>{item}</span>)
})}
{this.props.tag.map((item) => {
return (<span>{item<span>)
})}
我试图将这两个数组呈现为对Question1 => Tag1,然后在第二个Question2 => tag2等下面。
答案 0 :(得分:1)
使用索引 /**
* Possibility to lose precision at large numbers
* @param number
* @returns Number number
*/
var roundUpToNearestHundredth = function(number) {
// Ensure that we use high precision Number
number = Number(number);
// Save the original number so when we extract the Hundredth decimal place we don't bit switch or lose precision
var numberSave = Number(number.toFixed(0));
// Remove the "integer" values off the top of the number
number = number - numberSave;
// Get the Hundredth decimal places
number *= 100;
// Ceil the decimals. Therefore .15000001 will equal .151, etc.
number = Math.ceil(number);
// Put the decimals back into their correct spot
number /= 100;
// Add the "integer" back onto the number
return number + numberSave;
};
console.log(roundUpToNearestHundredth(6132423.1200000000001))
获取匹配的标签
类似的东西:
question