在写前端页面中,经常会在浏览器运行HTML页面,从本地文件夹中直接打开的一般都是file
协议,当代码中存在http
或https
node.js
官网地址: https://nodejs.org/ 下载完成后在命令行输入命令$ node -v
以及$ npm -v
检查版本,确认是否安装成功。
http-server
在终端输入: $ npm install http-server -g
http-server
服务终端进入目标文件夹,然后在终端输入:
1 $ http-server -c-1 (??只输入http-server的话,更新了代码后,页面不会同步更新) 2 Starting up http-server, serving ./ 3 Available on: 4 http://127.0.0.1:8080 5 http://192.168.8.196:8080 6 Hit CTRL-C to stop the server
http-server
服务按快捷键 CTRL-C
终端显示^Chttp-server stopped.
即关闭服务成功。
原文:https://www.cnblogs.com/zhuxuda/p/10560903.html