【发布时间】:2021-04-17 08:08:54
【问题描述】:
useEffect(() => {
axios.get("http://localhost:8080/application").then((response) => {
setListofApplications(response.data)
});
}, []);
<main id="body-content">
<div>
<Table>
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Display Name</th>
<th scope="col">Type</th>
<th scope="col">Response</th>
<th scope="col">Submitted Date</th>
<th scope="col">Approval</th>
</tr>
</thead>
<tbody>
{listofApplications.map((value) => {
let data =
JSON.parse(JSON.stringify(value.application_data));
return <tr>
<td>{value.id}</td>
<td>{value.display_name}</td>
<td>{value.application_type}</td>
<td>{data.first_name}</td>
<td>{value.createdAt}</td>
<td>{value.approval}</td>
</tr>
})}
</tbody>
</Table>
</div>
</main>
const initalValues= {
display_name: "",
applicaiton_data: [{
"first_name": '',
"middle_i": '',
"last_name": '',
"rp_name": '',
"age": '',
"email": '',
"history": '',
"expirence": '',
"why": '',
"bring": '',
"vac_ban": '',
}],
application_type: "",
approval: "false",
};
1 Test ca ["first_name":"test","middle_i":"test","last_name":"test","rp_name":"test","age":"test","email":"test","history":"test","experience":"test","why":"test","bring":"test","vac_ban":"test"] false 2021-04-17
(Response)
0:
application_data: "[
\"first_name\":\"test\",
\"middle_i\":\"test\",
\"last_name\":\"test\",
\"rp_name\":\"test\",
\"age\":\"test\",
\"email\":\"test\",
\"history\":\"test\",
\"experience\":\"test\",
\"why\":\"test\",
\"bring\":\"test\",
\"vac_ban\":\"test\
"]"
application_type: "ca"
approval: "false"
createdAt: "2021-04-17"
display_name: "Jerome_M"
id: 1
updatedAt: "2021-04-17"
这就是我返回页面的内容(不担心设计,只是想知道如何正确调用它。这些值一旦提交就不会改变,只是阅读。这就是我选择 json 路由的原因。
如何只显示字符串而不显示“”?
添加了我如何使用表格在页面上显示数据。如果我必须改变它,我不介意。只是想学习如何正确地做到这一点。
【问题讨论】:
-
您能否提供此输出的代码和框链接
-
你想读什么?底部的数组?你在哪里读它?
-
我不能,代码有两个部分客户端和服务器。但是代码的输出是 1 Test ca ["first_name":"test","middle_i":"test","last_name":"test","rp_name":"test","age":"test" ,"email":"test","history":"test","experience":"test","why":"test","bring":"test","vac_ban":"test"] false 2021-04-17
-
我已经在阅读它,它是通过使用 axios.get 从数据库中调用的 我只是打印出 {value.id} {value.display_name} {value.application_type} {value .application_data} {value.approval} {value.createdAt}
-
1 是 {value.id} 测试是 {value.dispay_name} ca 是 {value.application_type} 数组是 {value.application_data} false 是 {value.approval} 数据是 {value.createdAt }