app.js
var exppress = require("express"); const fs = require("fs"); var app = exppress(); app.use(exppress.static("dist")); const port = 3000; app.listen(port, () => { console.log(`服务已经启动 at http://localhost:${port}`); }); //服务端端路由 app.use(function (req, res, next) { //每次返回index.html fs.readFile(__dirname + "/dist/index.html", function (err, data) { if (err) { console.log(err); res.send("后台错误"); } else { res.writeHead(200, { "Content-type": "text/html", Connection: "keep-alive", }); res.end(data); } }); });