51Testing软件测试论坛
标题: BrowserSync 測試多個平台 [打印本页]
作者: yangxi123 时间: 2015-6-14 21:57
标题: BrowserSync 測試多個平台
- 1. Install Node.js
BrowserSync is a module for Node.js, a platform. for fast network applications. There are convenient installers for MacOS, Windows and Linux.51Testing软件测试网/I8@#n#~/q5} ?
- 2. Install BrowserSync
The Node.js package manager (npm) is used to install BrowserSync from
a repository. Open a terminal window and run the following command:
8`$I4}/]'r5u#`15010244npm install -g browser-syncYou’re telling the package manager to download the BrowserSync files and install them globally so they’re available to all your projects.51Testing软件测试网;d B#tI Ln4q
- 3. Start BrowserSync
A basic use is to watch all CSS files in the css directory and update connected browsers if a change occurs. Navigate your terminal window to a project and run the appropriate command:
6aWF%C&i~Y15010244Static sitesIf you’re only using .html files, you’ll need to use the server mode. BrowserSync will start a mini-server and provide a URL to view your site.51Testing软件测试网i*vrCl9~M
browser-sync start --server --files "css/*.css"Dynamic sitesIf you’re already running a local server with PHP or similar, you’ll need to use the proxy mode. BrowserSync will wrap your vhost with a proxy URL to view your site.
,d^&S@IU15010244browser-sync start --proxy "myproject.dev" --files "css/*.css"
51Testing软件测试网+F$^9Y+j$rCx
Ri!H0g(O_yh-K]15010244BrowserSync 是用 node.js 寫的工具,可以同時測試一堆 device,修改後不用按 reload,印象中已經有套件可以做類似的事情?51Testing软件测试网{9c7zC|V
一般用 npm 裝就可以了:
R5zfBN0{&q(E0J!p15010244npm install browser-sync最簡單的方法是直接執行 browser-sync,執行後會出現像這樣的訊息:51Testing软件测试网]#x"PU4_m!h.z
<script. src='//192.168.1.1:3000/socket.io/socket.io.js'></script><script>var ___socket___ = io.connect('http://192.168.1.1:3000');</script><script. src='//192.168.1.1:3001/client/browser-sync-client.0.6.0.js'></script>把這段程式碼貼到 body 的最後面就可以了,當 BrowerSync 偵測到檔案有更新時會透過 server push 機制重刷頁面。
e|6xx4Gw#]{e.i15010244另外,也可以產生 bs-config.js 修改設定:51Testing软件测试网0y6SpSvL8j(rKr%d
browser-sync --init
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) |
Powered by Discuz! X3.2 |