【发布时间】:2019-12-05 12:11:08
【问题描述】:
所以我只是想弄清楚如何在我的网页上的标题 (h1) 温度(摄氏度)下的输入框中显示来自我的 Data.json 文件的数据。我正在寻找最简单的方法。
这是我的html
<!doctype html>
<link rel="stylesheet" type="text/css" href="card.css">
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Filtered Input</title>
</head>
<body>
<div id="root"></div>
<h1>Temperature (Degrees Celsius)</h1>
<label>Enter List of Temperatures in Degrees Celsius here</label>
<input type="text" id='Data.json'>
<h2>Temperature (Degrees Farenheit)</h2>
<label>Enter List of Temperatures in Degrees Farenheit here</label>
<input type="text" id='new_element'>
</body>
还有我的css
h1 {
padding: 60px;
text-align: center;
background: #1abc9c;
color: white;
font-size: 40px;
}
h2 {
padding: 60px;
text-align: center;
background: #1abc9c;
color: white;
font-size: 40px;
}
这是我的 Data.json
[
{
"1": 23,
"2": 30,
"3": 40,
"4": 41,
"5": 19
}
]
【问题讨论】:
-
最简单的方法是复制您的 JSON 并将其粘贴到您的 HTML 文件中。