22模拟赛1
6 响应式Gulp中文网
@media (max-width: 1400px) and (min-width: 901px) {
nav .content {
width: 900px;
}
main section {
width: 900px;
}
}
@media (max-width: 900px) and (min-width: 651px) {
nav .content {
width: 700px;
}
main section {
width: 700px;
}
main ul li:nth-child(even) {
margin: 0;
}
main ul li {
float: none;
width: 100%;
}
}
@media (max-width: 650px) {
nav .content .list {
display: none;
}
nav .content {
width: 100%;
}
.content h1 {
width: 100%;
}
.content .menu {
display: block;
}
main section {
width: 100%;
}
main ul li:nth-child(even) {
margin: 0;
}
main ul li {
float: none;
width: 100%;
}
}
7 天气预报查询
function getweather() {
//TODO:请补充代码
fetch("./js/weather.json")
.then((res) => res.json())
.then((res) => {
let day=['Tuesday','Tuesday','Tuesday','Tuesday','Tuesday','Tuesday','Tuesday']
let data=res.result
document.querySelector('.week-weather').innerHTML= data.reduce((prev,curr, index)=>
prev+`<div class="item" id="${day[index]}">
<img src="${curr.weather_icon}">
<div class="item-mess">
<div>${curr.wind}</div>
<div>${curr.temperature}</div>
<div>${curr.winp}</div>
<div>
<span>${curr.days}</span>
<span>${curr.week}</span>
</div>
</div>
</div>`
,'')
});
}
getweather();
10 RESTful API开发
var express = require('express');
var app = express();
var fs = require("fs");
var path =require('path');
app.use(express.json())
app.use(express.urlencoded({ extended: false }))
app.post('/add', function(req, res) {
fs.readFile(path.resolve(__dirname,'./users.json'), 'utf8', function(err, data) {
data = JSON.parse(data);
data["userlist"].push({
"id": 4,
"username": "lucy",
"password": "123456"
});
res.json(data);
});
})
app.get('/list', function(req, res) {
fs.readFile(path.resolve(__dirname,'./users.json'), 'utf8', function(err, data) {
data = JSON.parse(data);
res.json(data);
});
})
app.listen(8080, function() {
console.log("访问地址:http://localhost:8080")
})
module.exports = app;