node.js - 如何重定向到public下的静态html文件
阿神
阿神 2017-04-17 14:44:53
0
2
590

利用res.res.redirect可以吗?

阿神
阿神

闭关修行中......

모든 응답(2)
伊谢尔伦

path.join(__dirname,'public','index.html')

阿神

如果你用的express, 那么app.use(express.static(path.join(__dirname, 'public')));设定静态文件路径, 这样的话你就可以直接访问public目录下的静态html了, 假如你的public目录下有个test.html, 在路由跳转的逻辑中加上res.redirect('/test.html')即可, public相当于根路径。

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿