Skip to content

Cannot correctly override onClick in v-bind #13868

@cangSDARM

Description

@cangSDARM

Vue version

3.5.13

Link to minimal reproduction

https://cn.vuejs.org/

Steps to reproduce

<script setup>
const { locale, t } = useI18n();

const items = [
    {
        title: 'change language',
        props: {
           onClick: () => (locale.value = locale.value === 'zh-CN' ? 'en-US' : 'zh-CN'),
        },
        disabled: true,
   },
]

const onClick = (e, item) => {
  if (item.disabled) return;

  item.onClick?.(e);

  if (item.children) {
    toggleExpand(item);
  }
};
</script>

<template>
<div
        v-for="(item, i) in items"
        :key="i"
        v-bind="item.props"
        v-on:click="(e) => onClick(e, item)"
      >
</div>
</template>

What is expected?

The item's onclick should be blocked from being triggered because it's disabled.

What is actually happening?

item.onclick is still triggered.

System Info

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions