【发布时间】:2020-05-01 22:42:35
【问题描述】:
我正在使用 React 而我的 home.js 是
import React, {Component} from "react";
import Data from "./questions.json"
class Home extends Component{
render(){return(
<div>
{Data.map((questionDetail, index)=>{
return <h1>{questionDetail.questions}</h1>
})}
</div>
)
}}
export default Home
Json 文件是
{
"questions":{
"question_one":"This is a question"
}}
如果有人知道这个问题的答案,我将非常感激。
【问题讨论】:
-
.map是数组上的函数。您显示的 json 不包含数组。
标签: javascript json reactjs file