1808a-day

**gulpfile.js** ```js const gulp = require('gulp'), url = require('url'), webServer = require('gulp-webserver'); gulp.task('run', (run) => { gulp.src('src') .pipe(webServer({ port: 8080, open: true,

Usage no npm install needed!

<script type="module">
  import 808aDay from 'https://cdn.skypack.dev/1808a-day';
</script>

README

npm init -y
npm install express

app.js 服务器端

const express = require('express');
const app = express();
app.use(express.static('public'));
app.listen(8080,()=>{console.log('http://127.0.0.1:8080/')});
app.get('/getUser', function (req, res) {
    res.send({name: 'zhangsan', password: 123456});
});

public>index.html

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="./index.css">
    <script src="./index.js"></script>
</head>
<body>
<div></div>
</body>
</html>

public>index.css

body{
    background-color: skyblue;
}

public>index.js 原生Ajax

const req = new XMLHttpRequest();
req.open('GET', '/getUser');
req.send();
req.onreadystatechange = function () {
    if (this.readyState === 4 && this.status === 200) {
        document.querySelector('div').innerHTML = this.responseText;
    }
}