<script>
var i = document.getElementById("header")
fetch("https://www.easy-mock.com/mock/5d2951ae92da6821fce72f31/list/list",
{
method: 'GET',
headers: { 'Content-Type': 'application/json;charset=utf-8' }
})
.then(response => {
return response.json();
})
.then(function (data) {
// console.log(data.data.map(item => item.img));
let cont = data.data.map(item => item.img);
let e = [];
let list = e = cont;
// for (var i = 0; i < cont.length; i++) {
// e.push(cont[i].img);
// }
for (let item of list.entries()) {
console.log(item);
}
for (let val of list) {
console.log(val);
}
})
.catch(function (err) {
console.log("err");
});
</script>
ES6 之 Dome-Fetch 请求与遍历
最新推荐文章于 2024-05-05 15:15:00 发布