<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial- scale=1.0">
<title>Document</title>
<script src="https://unpkg.com/vue@next"></script>
<style>
button{
background-color: red;
font-size: 32px;
color: rgb(245, 241, 241);
}
</style>
</head>
<body>
<button onclick="getData()">fecth</button>
<button onclick="getDataOne()">await</button>
<script>
//1. 实例演示fetch api, async,await的使用
function getData() {
fetch("http://xhr411.edu/users.php")
.then((response) => response.json())
.then((json) => console.log(json));
}
const url = "http://xhr411.edu/users.php";
async function getDataOne(){
const response = await fetch(url);
const result = await response.json();
console.log(result);
}
</script>
</body>
</html>
// 1. 核心模块
const http = require('http');
console.log(http);
// 2. 文件模块
const demo = require('./demo.js');
console.log(demo.getuser())
let user = "php.cn";
function getuser(){
return this.user;
}
exports.user = user;
exports.getuser = getuser;
相关推荐
© 2020 asciim码
人生就是一场修行