使用 node.js三行代码实现手机端访问html页面文件

  1. 首先确保你安装了node
  2. (全局安装) npm install -g browser-sync
  3. // --files 路径是相对于运行该命令的项目(目录) 
    browser-sync start --server --files "css/*.css, *.html"
    // 如果你的文件层级比较深,您可以考虑使用 **(表示任意目录)匹配,任意目录下任意.css 或 .html文件。 
    browser-sync start --server --files "**/*.css, **/*.html"

         在项目文件控制台中进行第三步,默认开启后是localhost,在浏览器中换成你的ip地址即可,然后在手机浏览器中输入url即可访问;

    tips:访问localhost(把localhost:8080换成你的项目的localhost):

      browser-sync start --proxy "localhost:8080" "**/*.css, **/*.html"

 

 

      更多细节:http://www.browsersync.cn/


新建了一个QQ群,群号: 1160215841 有关vue和element的知识几乎有问必答,欢迎进群~

posted @ 2019-08-19 19:01  william_new  阅读(1256)  评论(0编辑  收藏  举报