xhr.onload=function(){if(xhr.status===200){
console.log(xhr.responseText);var jsonData =JSON.parse(xhr.responseText)render(jsonData)}}functionrender(jsonData){var html = jsonData.data.list.map(item=>`
<li>
<img src="${item.imageUrl}"/>
<div>${item.name}</div>
<div>${item.note}</div>
</li>
`)
mylist.innerHTML = html
}
错误
Access to XMLHttpRequest at 'http://192.168.1.20:5500/data.json' from origin 'null' has been blocked by CORSpolicy: No 'Access-Control-Allow-Origin' header is present on the requested resource.01.html:17GEThttp://192.168.1.20:5500/data.json net::ERR_FAILED200(OK)