简体   繁体   English

当我在浏览器中输入 console.log 时,为什么谷歌浏览器没有显示结果?

[英]When I typed console.log to my browser, why does Google Chrome not showing me the result?

I'm a blind learner.我是一个盲学习者。 I want to test an expression like我想测试一个表达式

 console.log(1 + 2); function myFunction() { var a = 1 + 2; } console.log(myFunction());

But it is not showing me anything (not even errors).但它没有向我展示任何东西(甚至没有错误)。

I don't know if that is an accessibility issue.我不知道这是否是可访问性问题。

My browser is up-to-date.我的浏览器是最新的。

Any help will be greatly accepted.任何帮助都将被极大地接受。

Google Chrome does not make it easy for a visually impaired person to see the result of a console.log() statement in their Developer Tools Console. Google Chrome 无法让视障人士在其开发者工具控制台中轻松查看console.log()语句的结果。

I used NVDA in my experiments.我在实验中使用了 NVDA。 Your experience in other screen readers may be different.您在其他屏幕阅读器中的体验可能会有所不同。

  1. I entered console.log(1+2) and pressed Enter .我输入了console.log(1+2)并按下了Enter

  2. I pressed Shift + Tab .我按了 Shift + Tab

    This read "undefined", as that is the return value of console.log() .这读为“未定义”,因为那是console.log()的返回值。

  3. I pressed Left Arrow once.我按了一次左箭头

    This read "three".这读作“三”。

I can't imagine the experience of reading anything more complex would be.我无法想象阅读更复杂的东西会是怎样的体验。 Good luck.祝你好运。

Navigating and using developer tools is difficult at first with a screen reader, but it doesn't take long to get used to it.最初使用屏幕阅读器导航和使用开发人员工具很困难,但很快就会习惯。

First, have a read of this document from Google on devtools shortcuts you will find there are loads of shortcuts that you can use.首先, 从 Google 上阅读有关 devtools 快捷方式的文档,您会发现有很多可以使用的快捷方式。 This makes it easy to get used to navigating the console.这使得习惯于在控制台中导航变得很容易。

How to navigate in your example.如何在您的示例中导航。

What is confusing when you are not used to it is that the text that is logged to the console is attached to the line and character declaration (so for example it may read "VM50:1 3", explained below)当您不习惯时,令人困惑的是记录到控制台的文本附加到行和字符声明(例如,它可能显示为“VM50:1 3”,如下所述)

So in your example above you navigate to the previous item ( shift + Tab ) to get undefined as that is still what console.log(1+2) will return.因此,在上面的示例中,您导航到上一项( shift + Tab )以获取undefined ,因为这仍然是console.log(1+2)将返回的内容。

Then if you press the Up arrow it will focus a link and announce "link vm50:1 3" where "link vm50:1" is line and character number and "3" is the answer.然后,如果您按向上箭头,它将聚焦一个链接并宣布“link vm50:1 3”,其中“link vm50:1”是行号和字符号,“3”是答案。

An easier way to understand this is to log some words to the console instead, if you log "I like cheese, it is yummy" you will get something like "VM50:1 I like cheese, it is yummy"理解这一点的更简单方法是将一些单词记录到控制台,如果你记录“我喜欢奶酪,它很好吃”,你会得到类似“VM50:1 我喜欢奶酪,它很好吃”的信息

One thing that can be confusing is when you get an error that results in a stack trace (as we are reading from the bottom to the top).可能令人困惑的一件事是当您收到导致堆栈跟踪的错误时(因为我们是从底部到顶部读取)。 For that I tend to spam the up arrow until I don't hear "at" and get a script name as that will announce the error as well.为此,我倾向于向向上箭头发送垃圾邮件,直到我听不到“at”并获得脚本名称,因为这也会宣布错误。

Finally try navigating via links ( Shift + K in NVDA) as that can also be a quick way to get to errors (although can be confusing if you get a stack trace as above).最后尝试通过链接导航(NVDA 中的Shift + K ),因为这也是一种快速解决错误的方法(尽管如果您获得上述堆栈跟踪可能会令人困惑)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM