V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
TWorldIsNButThis
V2EX  ›  前端开发

调试 dropdown 的正确姿势是?

  •  
  •   TWorldIsNButThis · 2023-02-12 19:11:29 +08:00 · 818 次点击
    这是一个创建于 410 天前的主题,其中的信息可能已经有所发展或是发生改变。
    现在很多组件库 select 的 dropdown 都不是通过原生的 select 实现的
    focus 状态消失就立即收回去了,也无法设置 element state 触发弹出
    目前知道的一个方式就是在 console 里 setTimeout(() => {debugger}, 3000),
    然后在 3 秒内点开让它暂停在那,有没有更直接的方式?
    5 条回复    2023-02-26 08:13:18 +08:00
    Baymaxbowen
        1
    Baymaxbowen  
       2023-02-12 19:23:07 +08:00 via iPhone
    css display none 干掉
    hangbale
        2
    hangbale  
       2023-02-12 19:23:36 +08:00
    Dom 断点
    BigOldBrother
        3
    BigOldBrother  
       2023-02-12 19:25:15 +08:00
    打开控制台之后,先 focus select 组件,弹出 dropdwon 之后用快捷键( cmd + shift + C )选择
    TWorldIsNButThis
        4
    TWorldIsNButThis  
    OP
       2023-02-12 19:48:49 +08:00
    @BigOldBrother 很多组件切到选中状态的时候就消失了,比如知乎首页的搜索框


    @hangbale 原理好像和 debugger 类似,不过应该触发更可控 👍
    chnwillliu
        5
    chnwillliu  
       2023-02-26 08:13:18 +08:00 via Android   ❤️ 1
    Chrome devtools 可以让页面保持停留在聚焦状态同时你还能操作 devtools. 搜 Emulate a focused page ,enable 即可。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3262 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 14:16 · PVG 22:16 · LAX 07:16 · JFK 10:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.