1、首先全局安装http-server
yarn global add - http-server
或者打开git-bash输入npm i -g http-server
2、点击进入映射文件夹里面执行:
cd /Users/lyb/myWorkSpace/icnpt-res
http-server -p 8888
有个问题需要注意:
1、html文件最好命名为index,因为http默认会打开index,这样输入以上两个地址就可以直接进入网页。
如果index.html用别的命名,比如命名为html.html,这样就不能直接打开网页,而是打开一个索引,需要手动点击html.html才可以打开。