Skip to content

a-input 组件不受控 #7721

@guaijie

Description

@guaijie
  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

undefined

Environment

vue: 3.x ; ant-design-vue: 4.2.3

Reproduction link

Edit on CodeSandbox

Steps to reproduce

<script setup>
import { ref } from 'vue'

const msg = ref('Hello World!')
const handleInput = () => msg.value = 'Hello'
</script>

<template>
<h1>{{ msg }}</h1>
<input v-model="msg" @change="handleInput" />
</template>

https://play.vuejs.org/#eNp9UctqwzAQ/JWtLk4gtSntKTihDwJND21pC73oYpyNo1SWhB5uwPjfu1JImkPITTszuzODevZgTN4FZFNWutoK48GhD2bOlWiNth56sLiGAdZWt5CRNOOKq1or56F1DcwiP8qeUUoN39rK1VU2Pgg2lVpJXCoTPAlHY5jN41LeVTIgIfs1ulgWe3fypcFja2TlkSaAcnMz7/vkNQxlQVNCRTraXbd6hXLGGfGcwX2CaTxxJrignbI4OcsmzDvKuBZNvnVaUf8 nuWs1q0REu2b8YI6cDaFxESuorC/LwnzNuDkgNcbrH/O4Fu3ixhn7xYd2g45O3K sg1StkgvPl9xR 8jSaWCJPUF8gOdliFm3MseQyxsT3Qp7TL9olDNl1vsPCp3KBWDRuWQ9JzRzz5dqP4f9za/S3tcDWz4A1ABvuE=
使用原生的 input 组件,input 输入的内容由 msg 决定,我通过 change 事件来重新对 msg 赋值,会发现输入框的数据不会变化

但使用 a-input 组件却不受 msg 的控制

<script setup>
import { ref } from 'vue'

const msg = ref('Hello World!')
const handleChange = () => msg.value = 'Hello'
</script>

<template>
<h1>{{ msg }}</h1>
<a-input v-model:value="msg" @change="handleChange " />
</template>

What is expected?

期待 a-input 组件与原生组件 input 特征保持一致,其显示的内容受控

What is actually happening?

no response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions