全局安裝:npm install -g browser-sync //-g是全局安裝
browser-sync start --server --files "*.html」 //執行完這句以後,會自動幫你打開瀏覽器http://localhost:3000
解釋一下 start表示啓動 --server表示已經啓動的http服務 --files後面是你要監視的文件名,*.html表示你要監視這個項目下的全部後綴爲.html的文件html
如果你想監視指定文件,就直接寫文名就好,例如:browser-sync start --server --files "index.html
,就是把*改爲具體的前端
browser-sync的能力不單單如此,實現了無刷新。npm
http://localhost:3000
,還有一個http://localhost:3001
http://localhost:3001
,就會出現一個界面,這是一個管理的後臺,點擊左側邊欄的sync options
,裏面的選項是能夠選擇的,舉個例子:若是你把Scroll
的按鈕關掉。那麼這各個瀏覽器之間就不會同步了Remote Debug
,而後點擊第一項Remote Debugger (weinre)
,點擊下面的字,就會跳轉到另外一個頁面。裏面就跟瀏覽器裏面差很少,有elements,console等,你就能夠在裏面查看啦