1. 使用 http-server-spa
- 全局安装 http-server-spa
yarn global add http-server-spa
// 或者
npm i -g http-server-spa
- 运行
// http-server-spa <directory> <fallback> <port>
// 运行 dist 为目录,index.html 启动文件,端口 8080
http-server-spa ./dist/ index.html 8080
ps: ./dist/ 后面有个空格
- 浏览器输入 localhost:8080

- http-server也可以,差不多的方法,想用可以自行百度
2. 使用nginx
- 下载nginx
官网下载地址 - 解压, 打开conf文件夹,找到nginx.conf文件

- 修改端口号 和 文件路径

- 启动nginx

- 浏览器输入 localhost:8088

- 还有express本地服务器的方法, 大同小异,百度一下, 略略略…
本文介绍了两种本地服务器搭建方法:使用http-server-spa快速启动静态文件服务器,以及通过下载并配置nginx实现。对于http-server-spa,详细说明了安装和运行步骤,包括指定目录、启动文件和端口。对于nginx,讲解了下载、配置端口和文件路径,以及启动服务器的过程。这两种方法都是为了在本地运行和测试前端应用。
276

被折叠的 条评论
为什么被折叠?



