“警报不好” - 真的吗? [英] "Alert is bad" - really?

查看:117
本文介绍了“警报不好” - 真的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有这种想法在警告()错误中运行。

There's this idea running around that "alert() is bad".

致谢:


  • 当然,我们很少想在实际中使用它UI设计,因为有更好的方式与用户沟通。

  • 对于调试, console.log()的价值远远超过 alert()

  • 某些情况(如使用 setTimeout )遇到当 alert()阻碍时出现问题。

  • 实际调试器处理暂停和恢复执行的效果远远优于 alert(),如果这是开发人员需要的。

  • Sure, we rarely want to use it in an actual UI design since there are better ways to communicate with users.
  • For debugging, console.log() has much more value than alert().
  • Certain situations (like use of setTimeout) run into problems when alert() gets in the way.
  • Actual debuggers handle pausing and resuming of execution much better than alert(), if that's what a developer needs.

问题:


  1. 从不使用 alert()是否有充分合理的理由?

  2. console.log()的增加值是否真正降低了 alert()的值如此大幅度地从有限的情况下有用变为糟糕?

  3. 你对想要使用警报的人怎么说? ()在一个简短的测试中,loggin g没有设置,任何副作用都无关紧要(想想教程或快速原型)?

  1. Is there a solid, logical reason to never use alert()?
  2. Does the increased value of console.log() truly reduce the value of alert() so drastically that it goes from "useful in limited scenarios" to "bad"?
  3. What do you say to someone who wants to use alert() in a brief test where logging is not setup and any side effects are irrelevant (think tutorials or quick prototypes)?


推荐答案


是否有一个坚实的,合理的理由永远不会使用alert()?

Is there a solid, logical reason to never use alert()?

警报很糟糕只是因为它没有积极的功能,只有负面功能

alert is bad simply because it has no positive features and only negative features


  • 阻止整个浏览器

  • 阻止javascript线程

  • 仅打印字符串

  • 要求用户交互继续(这意味着您无法自动化浏览器使用)

  • 被常见弹出窗口阻止程序阻止

  • 在node.js等非浏览器环境中不起作用(但是console.log在node.js中可以正常工作)

  • blocks the entire browser
  • blocks the javascript thread
  • only prints strings
  • requires user interaction to continue (this means you can't automate browser usage)
  • is blocked by common popup blockers
  • doesn't work in non-browser environments like node.js (however console.log does work in node.js)

console.log()的增加值是否真的会大大减少alert()的值,使其从有用变为有用在有限的情况下到坏?

Does the increased value of console.log() truly reduce the value of alert() so drastically that it goes from "useful in limited scenarios" to "bad"?

是的,虽然有是一些例外

Yes, although there are some exceptions

警报的唯一值是作为调试旧版浏览器的快速黑客工具或作为惹恼用户的工具。

The only value alert has is as a quick hackish tool to debug legacy browser or as a tool to annoy users.

这篇关于“警报不好” - 真的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆