45 lines
1.2 KiB
HTML
45 lines
1.2 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<title>Title</title>
|
||
</head>
|
||
<body>
|
||
<ul>
|
||
|
||
</ul>
|
||
</body>
|
||
<script src="http://127.0.0.1:3000/api/index" ></script>
|
||
<script>
|
||
// // 先拿出电话
|
||
// var http = new XMLHttpRequest();
|
||
// // 输入号码(里面有 GET, POST,PUT,DELETE,OPTION等方法)
|
||
// http.open("GET","http://127.0.0.1:3000/api/index");
|
||
// // 拨打号码
|
||
// http.send()
|
||
// //
|
||
// http.onreadystatechange = function (){
|
||
// if (http.readyState==4)
|
||
// {
|
||
// if (http.status==200){
|
||
// var res = JSON.parse(http.responseText)
|
||
// console.log(res)
|
||
// res.data.forEach((value, index) =>{
|
||
// console.log(value)
|
||
// document.querySelector("ul").innerHTML +=`<li>${value.title}</li>`
|
||
// })
|
||
// }
|
||
// else {
|
||
// alert("网络不好 ")
|
||
// }
|
||
// // console.log( http.responseText)
|
||
// //将字符串转化为对象
|
||
// // console.log(JSON.parse(http.responseText))
|
||
// //将对象转化字符串
|
||
// // console.log(JSON.stringify(http.responseText))
|
||
//
|
||
// }
|
||
// }
|
||
|
||
</script>
|
||
</html> |