Write the Code. Change the World.

3月 06

daisyui 的 Dropdown 组件,点击展开对象时,怎么自动关闭展开对象呢?daisyui 默认没提供这个功能。只需要在点击对象时,触发 blur 方法即可。

if (document.activeElement instanceof HTMLElement) {
    document.activeElement.blur()
}