Skip to content

vue3中jsx中使用withModifiers阻止子元素点击事件冒泡到父元素

withModifiers

用于向事件处理函数添加内置 v-on 修饰符。

类型

jsx
const columns = [
    {
        title: '文件名', key: 'name', render: (row) => {
            return <div onClick={() => handleClickName(row)} style="cursor: pointer;width: 100%"
                        class="fx al-ct ju-sb fx-gp02 mouse-active-show-container">
                <div class="fx al-ct fx-gp05">
                    {readerFileIcon(row)}
                    <span>{row.name}</span>
                </div>
                {
                    row.type === 'folder'
                        ? <n-icon class="mouse-active-show-element" size="20">
                            <Close onClick={withModifiers(() => handleClickDeleteFolder(row), ['stop'])}/>
                        </n-icon>
                        : null
                }

            </div>
        }
    }
]
/src/technology/dateblog/2025/05/20250521-vue3%E4%B8%ADjsx%E4%B8%AD%E4%BD%BF%E7%94%A8withmodifiers%E9%98%BB%E6%AD%A2%E5%AD%90%E5%85%83%E7%B4%A0%E7%82%B9%E5%87%BB%E4%BA%8B%E4%BB%B6%E5%86%92%E6%B3%A1%E5%88%B0%E7%88%B6%E5%85%83%E7%B4%A0.html