前端在本地启动服务预览html页面(http-server)

npm: http-server

  • 安装
1
npm install --global http-server
  • 使用
    • 切到需要预览的html文件的目录下执行:http-server
    • 此时默认启动的是index.html文件
    • 在网页输入:http://localhost:8080/,即可访问index.html文件的渲染效果
    • 若要访问同目录下非index.html的文件,则在http://localhost:8080/后追加文件名例如:http://localhost:8080/index-demo.html