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.mzph.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…