node服务器配置history模式

315 阅读1分钟
    const path = require('path')
    导入处理history模式的模块
    const history = require('content-history-api-fallback')
    导入express模块
    const express = require('express')
    const app = express()
    处理history模式中间接
    app.use(history())
    处理静态资源中间件网站根目录 ../web
    app.use(express.static(path.join(_dirname,'../web'))
    开启服务端口
    app.listen(3000,()=>{
        console.log('服务器已开启,端口:3000')
    })