51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2372|回复: 0
打印 上一主题 下一主题

[转贴] BrowserSync 測試多個平台

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2015-6-14 21:57:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  • 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-sync
    You’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 sites
    If 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 sites
    If 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]15010244

BrowserSync 是用 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软件测试网0y6SpS vL8j(rK r%d

browser-sync --init
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-11-15 15:46 , Processed in 0.065580 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表