chrome前端開發工具_精通Chrome開發人員工具:更高級別的前端開發技術

chrome前端開發工具

by Ben Edelstein

通過本·愛德斯坦

You may already be familiar with the basic features of the Chrome Developer Tools: the DOM inspector, styles panel, and JavaScript console. But there are a number of lesser-known features that can dramatically improve your debugging or app creation workflows.

您可能已經熟悉Chrome開發人員工具的基本功能:DOM檢查器,樣式面板和JavaScript控制臺。 但是,有許多鮮為人知的功能可以極大地改善調試或應用程序創建工作流程。

黑暗主題 (Dark Theme)

Chrome comes with a built-in dark theme for the dev tools. You can enable it by clicking the three dots icon in the upper right of the dev tools pane, clicking “settings”, and then toggling the theme.

Chrome帶有內置深色主題的開發工具。 您可以通過單擊開發工具窗格右上方的三個點圖標,單擊“設置”,然后切換主題來啟用它。

I sometimes find this easier on my eyes, and, obviously, it looks much cooler :)

有時我覺得這更容易些,而且顯然很酷:)

選擇方式 (Selection Mode)

Chrome Developer Tools (DevTools) offer a number of ways to select elements — the most convenient of which is the selection mode.

Chrome開發者工具(DevTools)提供了多種選擇元素的方法-最方便的是選擇模式。

This tool, activated by pressing the mouse icon in the upper-left corner of the dev tools panel (or with cmd + shift + c), lets you select elements on the page simply by clicking on them.

通過按下開發工具面板左上角的鼠標圖標(或使用cmd + shift + c)激活該工具,只需單擊一下即可在頁面上選擇元素。

Once activated, you can move your mouse around the page and preview selection, then click to select an element to inspect. This tool is great for quickly selecting an element on the page since hitting cmd + shift + c will open the dev tools and go straight into selection mode.

激活后,您可以在頁面上移動鼠標并預覽選擇,然后單擊以選擇要檢查的元素。 該工具非常適合快速選擇頁面上的元素,因為按cmd + shift + c會打開開發工具并直接進入選擇模式。

存儲為全局變量 (Store as global variable)

Inspecting complicated objects that are logged to the console can sometimes be tricky if they have many keys, or contain values that are hard to parse manually. Luckily, Chrome makes it easy to inspect such objects with JavaScript.

如果復雜的對象有很多鍵,或者包含難以手動解析的值,則檢查登錄到控制臺的復雜對象有時可能很棘手。 幸運的是,Chrome使使用JavaScript輕松檢查此類對象變得容易。

To do so, right click on an object in the console and press “store as global variable”. This stores the object as a global variable accessible in the console called temp1 which you can then work with using JavaScript.

為此,請在控制臺中右鍵單擊一個對象,然后按“存儲為全局變量”。 它將對象存儲為全局變量,該全局變量可在名為temp1的控制臺中訪問,然后可以使用JavaScript進行操作。

動畫工具 (Animation Tools)

Recently, the Chrome team added a number of new features for debugging and for creating animations.

最近,Chrome團隊添加了許多新功能,用于調試和創建動畫。

Clicking the dropdown in the upper-left corner of the console reveals an “Animations” pane that lets you limit the speed for all animations on a site.

單擊控制臺左上角的下拉菜單,將顯示一個“動畫”窗格,可用于限制網站上所有動畫的速度。

You can also pause all animations. This is particularly useful for a site that is buzzing with animated content.

您也可以暫停所有動畫。 這對于充斥著動畫內容的網站特別有用。

Clicking on the purple curve icon in an element’s transition property lets you view the motion curve for an animation, and fine-tune its properties. In addition, you can use the arrow icons to scroll through a list of preset animations to apply to your element.

單擊元素的transition屬性中的紫色曲線圖標,可以查看動畫的運動曲線,并對其屬性進行微調。 另外,您可以使用箭頭圖標滾動瀏覽要應用于您的元素的預設動畫列表。

模擬元素偽狀態 (Simulate Element Pseudo State)

Another handy tool for styling elements is the element state simulator, which is accessed by clicking the :hov icon in the upper-right corner of the Styles panel.

另一個用于設置元素樣式的便捷工具是元素狀態模擬器,可通過單擊“樣式”面板右上角的:hov圖標來訪問它。

This tool lets you simulate the element pseudo states of hover, active, focused, and visited and view styles that are associated with those selectors.

使用此工具,您可以模擬懸停,活動,集中和訪問的元素偽狀態以及與這些選擇器關聯的樣式。

To add styles for those pseudo states, add a new selector (with the + icon) and add :<state> to the end of the selector string.

要為這些偽狀態添加樣式,請添加一個新的選擇器(帶有+圖標),并將:<sta te>添加到選擇器字符串的末尾。

For example, to add a hover rule to an li with class logo, make a new selector, li.logo:hover, and add styles there.

例如,要向帶有class logoli添加一個懸停規則,請創建一個新的選擇器li.logo:hover ,并在其中添加樣式。

You can then test your styles by checking the :hover element state to simulate hovering on the element.

然后,您可以通過檢查:hover元素狀態以模擬元素上的:hover來測試樣式。

美化CSS和JavaScript (Prettify CSS and JavaScript)

Debugging or viewing minified JavaScript and CSS is very difficult. But luckily DevTools provides a tool that makes doing this a bit easier.

調試或查看縮小JavaScript和CSS非常困難。 但是幸運的是,DevTools提供了一個使此操作變得容易一些的工具。

After opening a minified file in the “Sources” tab, you can click the brackets logo in the lower left corner of the file, and DevTools will “prettify” the code.

在“源”選項卡中打開縮小的文件后,您可以單擊文件左下角的方括號徽標,DevTools將“整理”代碼。

This works quite well with CSS files, and does a decent job with JavaScript, though some information (like variable names) is lost in the minification process.

盡管在縮小過程中會丟失一些信息(例如變量名),但這在CSS文件上工作得很好,并且在JavaScript上也做得不錯。

Alt +向上/ Alt +向下 (Alt + Up / Alt + Down)

When debugging CSS, you can select a property and use the up/down keys to tweak it’s value. By default, the arrow keys adjust values by +/- 1. However, by holding the alt key, you can use the arrow keys to adjust values finely in steps of 0.1, which is particularly useful when working with fractional values.

調試CSS時,您可以選擇一個屬性,然后使用向上/向下鍵調整其值。 默認情況下,箭頭鍵將值調整+/- 1 。 但是,通過按住alt鍵,您可以使用箭頭鍵以0.1步長精細調整值,這在處理分數值時特別有用。

Conversely, you can hold shift to adjust values in steps of 10.

相反,您可以按住shift鍵以10步長調整值。

保留日志 (Preserve Log)

Preserve log is a checkbox that lets you persist logs between page refreshes. This is useful when debugging website issues that require you to refresh the page, since all console output is otherwise cleared.

保留日志是一個復選框,可讓您在頁面刷新之間保留日志。 在調試需要刷新頁面的網站問題時,此功能很有用,因為否則會清除所有控制臺輸出。

When this option is enabled, a new type of “Navigation” log appears in the console to show page refreshes or navigation events to different pages.

啟用此選項后,控制臺中將出現一種新型的“導航”日志,以顯示頁面刷新或導航到不同頁面的事件。

網絡+日志過濾器 (Network + Log Filters)

When debugging an app that has a lot of network requests or console logs, it can be useful to filter for particular types of events.

調試具有大量網絡請求或控制臺日志的應用程序時,篩選特定類型的事件可能很有用。

Chrome has a filtering language that supports many different properties, as well as operators like * to do wildcard matches.

Chrome的過濾語言支持許多不同的屬性,以及*運算符可進行通配符匹配。

If you type “-”, Chrome will expose a typeahead that shows the various properties you can filter for. You can also toggle on “regex” mode to do a regex match on the data shown in each row.

如果您輸入“-”,Chrome將顯示一個預輸入內容,顯示您可以過濾的各種屬性。 您也可以啟用“正則表達式”模式以對每行中顯示的數據進行正則表達式匹配。

代碼覆蓋率 (Code Coverage)

Code coverage lets you run your web app, then for each JavaScript and CSS file, see which lines of code ran and which didn’t. This is helpful since when working on a complex or long-term project, it is easy to accumulate dead code.

代碼覆蓋率使您可以運行Web應用程序,然后針對每個JavaScript和CSS文件查看已運行的代碼行和未運行的代碼行。 這很有用,因為在進行復雜或長期的項目時,很容易積累無效代碼。

To use it, make sure you have Chrome 59 or higher, and go to the “Coverage” tab. Press “record” and then start using your app. When you’re done, Chrome will show you the exact code that ran during your session.

要使用它,請確保您擁有Chrome 59或更高版本,然后轉到“覆蓋率”標簽。 按“記錄”,然后開始使用您的應用程序。 完成后,Chrome會向您顯示會話中運行的確切代碼。

生產中的調試問題 (Debugging Issues in Production)

DevTools only works if you’re running your app on your own machine. If you’re interested in understanding bugs and performance issues that users see in production, try LogRocket.

僅當您在自己的計算機上運行應用程序時,DevTools才有效。 如果您想了解用戶在生產中看到的錯誤和性能問題,請嘗試LogRocket 。

LogRocket is a front-end logging tool that lets you replay problems as if they happened in your own browser. Instead of guessing why errors happen, or asking users for screenshots and log dumps, LogRocket lets you replay the session to quickly understand what went wrong. It works perfectly with any app, regardless of framework, and has plugins to log additional context from React, Angular, and Vue.js.

LogRocket是一個前端日志記錄工具,可讓您像在您自己的瀏覽器中一樣重播問題。 LogRocket無需猜測錯誤發生的原因,也不要求用戶提供屏幕截圖和日志轉儲,而是讓您重播會話以快速了解問題所在。 無論框架如何,它都可以完美地與任何應用程序配合使用,并且具有用于記錄來自React,Angular和Vue.js的其他上下文的插件。

LogRocket instruments your app to record console logs, network requests/responses with headers + bodies, browser metadata, Redux actions/state, and performance timings. It also records the HTML and CSS on the page, recreating pixel-perfect videos of even the most complex single-page apps.

LogRocket使用您的應用程序來記錄控制臺日志,帶有標頭+正文的網絡請求/響應,瀏覽器元數據,Redux操作/狀態以及性能計時。 它還將HTML和CSS記錄在頁面上,甚至可以對最復雜的單頁面應用程序重新創建像素完美的視頻。

You can check out LogRocket here.

您可以在此處簽出LogRocket 。

LogRocket | Logging and Session Replay for JavaScript AppsLogRocket helps you understand problems affecting your users, so that you can get back to building great software.logrocket.com

LogRocket | JavaScript應用程序的日志記錄和會話重播 LogRocket可幫助您了解影響用戶的問題,以便您可以重新構建出色的軟件。 logrocket.com

Thanks for reading. I hope these advanced DevTools techniques help you build better apps with less stress.

謝謝閱讀。 我希望這些先進的DevTools技術可以幫助您以更少的壓力構建更好的應用程序。

翻譯自: https://www.freecodecamp.org/news/mastering-chrome-developer-tools-next-level-front-end-development-techniques-3ac0b6fe8a3/

chrome前端開發工具

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/395534.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/395534.shtml
英文地址,請注明出處:http://en.pswp.cn/news/395534.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

linux給文件夾圖標,linux – 如何在GNOME中以編程方式設置自定義文件夾圖標?

我終于想出了如何做到這一點&#xff01;這是一個在標準Gnome環境中工作的Python腳本&#xff1a;#!/usr/bin/env pythonimport sysfrom gi.repository import Gioif len(sys.argv) not in (2, 3):print Usage: {} FOLDER [ICON].format(sys.argv[0])print Leave out ICON to u…

jQuery序列化表單為JSON對象

[html] view plaincopy <form id"myform"> <table> <tr> <td>姓名:</td> <td> <input type"text" name"name" /> </td> </tr> …

sys模塊

與python解釋器交互的模塊 sys.argv 命令行參數List&#xff0c;第一個元素是程序本身路徑 sys.exit(n) 退出程序&#xff0c;正常退出時exit(0),錯誤退出sys.exit(1) sys.version 獲取Python解釋程序的版本信息 sys.path 返回模塊的搜索路徑…

李開復:年輕人該比誰更拼命嗎?

李開復:年輕人該比誰更拼命嗎&#xff1f; IT職場 cricode 4個月前 (04-02) 951℃ 0評論 我年輕的時候是最不注重睡眠的&#xff0c;我記得在我讀大學的時候每次要考試就因為平時玩耍太多了&#xff0c;每次要考試的時候就會灌咖啡&#xff0c;有時候一個晚上可以喝十杯咖啡不…

linux命令無視錯誤,llinux 的一些命令和錯誤

sudo tar -zxvf ./hadoop-2.6.0.tar.gz -C /usr/local # 解壓到/usr/local中source ~/.bashrc # 使變量設置生效sudo useradd -m hadoop -s /bin/bash 創建新用戶sudo adduser hadoop sudo 可為 hadoop 用戶增加管理員權限sudo mv ./hadoop-2.6.0/ ./hadoop # 將文件…

假設檢驗方差未知_設計云數據庫時如何處理未知數并做出假設

假設檢驗方差未知by Rick Mak麥瑞克(Rick Mak) 設計云數據庫時如何處理未知數并做出假設 (How to handle unknowns and make assumptions when designing a cloud database) 場景&#xff1a;鞋盒還是社交應用&#xff1f; (Scenario: Shoebox or social app?) Say you’re a…

SQL校驗優化

我的思路只能查當前的&#xff1a; ----校驗此行訂單是否已導入&#xff0c;若已導入則提示訂單號并Return -- IF EXISTS (SELECT 1 FROM DOC_Order_Header b LEFT JOIN tblData a -- ON -- a.ConsigneeID b.Consig…

nat64 dns64 linux 內核支持,搭建NAT64/DNS6實現IPv4/v6轉換

NAT64采用tayga實現&#xff0c;DNS64采用bind9.8實現。1 平臺搭建平臺為ubuntu12.04 Desktop版本。正常安裝即可。2 NAT64(tayga)2.1 安裝在終端模式下輸入sudo apt-get install tayga2.2 配置2.2.1 相關設置sudo gedit /etc/tayga.conf按照說明配置&#xff0c;目前實現方案不…

React學習筆記(持續更新)

2.2頁面加載過程 1.資源加載過程&#xff1a;URL->DNS查詢->資源請求->瀏覽器解析 ①URL結構&#xff1a;http://www.hhh.com:80/getdata?pid1#title[協議://域名&#xff1a;端口/路徑?參數#哈希] ②DNS查詢&#xff1a;瀏覽器<--&#xff08;ip&#xff09;&am…

2年工作經驗進 初創公司_溝通是關鍵:通過兩家初創公司獲得的成長經驗教訓+找工作...

2年工作經驗進 初創公司by Niki Agrawal通過尼基阿格勞瓦爾(Niki Agrawal) 溝通是關鍵&#xff1a;通過兩家初創公司獲得的成長經驗教訓找工作 (Communication is key: growth lessons learned through two startups a job hunt) It’s been a crazy two years. I founded tw…

Hibernate問題淺析

1、什么是SessionFactory&#xff1f;什么是Session&#xff1f;httpsession和hibernate的session的有什么區別&#xff1f;SessionFactory接口負責初始化Hibernate。它充當數據存儲源的代理&#xff0c;并負責創建Session對象。這里用到了工廠模式。需要注意的是SessionFactor…

Oracle中SQL語句學習五(統計分組語句group by和having)

oracle&#xff08;41&#xff09; 在 應用系統開發中&#xff0c;進行需要統計數據庫中的數據&#xff0c;當執行數據統計時&#xff0c;需要將表中的數據進行分組顯示&#xff0c;在統計分組中是通過group by子句、分組函數、having子句共同實現的。其中group by子句用于指定…

linux系統去吧,要開始另一個linux操作系統的嘗試了,說說我以前的ubuntu吧

我想&#xff0c;除了嘗試一下ubuntu的神奇魅力的同時&#xff0c;我應該去體驗一下RedHat的神奇吧&#xff01;馬上就要告別ubuntu了&#xff0c;我想把我的部分使用經歷和大家分享分享&#xff01;首先&#xff0c;無論是ubuntu8.04、10.04還是10.1的效果都是很好的&#xff…

課程編碼查詢_付出還是不付出:生活中最好的事情(例如編碼課程)是否免費?...

課程編碼查詢by Rick West由里克韋斯特(Rick West) 付出還是不付出&#xff1a;生活中最好的事情(例如編碼課程)是否免費&#xff1f; (To pay or not to pay: are the best things in life — like coding courses — free?) Recently, I’ve been working on a project tha…

做開發十年,我總結出了這些開發經驗

本文由云社區發表,原文轉載地址:https://www.cnblogs.com/qcloud1001/p/10218876.html 在一線做了十年的開發&#xff0c;經歷了網易、百度、騰訊研究院、MIG 等幾個地方&#xff0c;陸續做過 3D 游戲、2D 頁游、瀏覽器、移動端翻譯 app 等。 積累了一些感悟。必然有依然幼稚的…

2016年4月 TIOBE 編程語言排行榜

4月頭條: Visual Basic 正在漸行漸遠 COBOL, BASIC 和 FORTRAN 很長一段時間作為主力開發語言被使用。有很多軟件使用這些語言來編寫&#xff0c;并且發展的不亦樂乎。然而經過多年的發展&#xff0c;COBOL和FORTRAN逐漸被拋棄&#xff0c;而得益于微軟的存在&#xff0c;BASIC…

linux系統不知道電腦密碼怎么辦,Linux如何修復系統的Root密碼 -電腦資料

如果因為忘了root口令導致無法登錄系統&#xff0c;請試用下面的方法來改忘記的root口令&#xff1a;方法一&#xff1a;1、重新啟動系統&#xff0c;2、把光標定位在該選項上按下字母“e”鍵進入這個引導的編輯狀態&#xff1b;3、該選項有三行語句&#xff0c;請用光標選中第…

控制語句(4)

第4章 控制語句if<條件1>&#xff1a; <語句1>elif<條件2>: <語句2>elif<條件3>&#xff1a; <語句3>......else: <語句n>說明&#xff1a;elif語句&#xff0c;只要有一個條件成立&#xff0c;就會將其后的一個部分語句執行…

02 socketserver客戶端

import socket client socket.socket() client.connect((127.0.0.1,8001))while 1:msg input(客戶端說>>>)client.send(msg.encode(utf-8))from_server_msg client.recv(1024)print(from_server_msg.decode(utf-8)) 轉載于:https://www.cnblogs.com/work14/p/10235…

基于zbus的MySQL透明代理(100行)

項目地址 https://git.oschina.net/rushmore/zbus 我們上次講到zbus網絡通訊的核心API&#xff1a; Dispatcher -- 負責-NIO網絡事件Selector引擎的管理&#xff0c;對Selector引擎負載均衡 IoAdaptor -- 網絡事件的處理&#xff0c;服務器與客戶端共用&#xff0c;負責讀寫&am…