【问题标题】:Ant Design input Issue for v-decorator and v-model showing database records for update in Vue JSv-decorator 和 v-model 的 Ant Design 输入问题,显示 Vue JS 中更新的数据库记录
【发布时间】:2021-05-29 05:06:13
【问题描述】:

大家好,请告诉我如何解决这些问题。 问题 1. a-input v-decorator="['name']" initialValue="record.name"> 在输入中不显示来自数据库的数据,但可以在输入内容并提交表单后编辑值。这是我完整的html代码

<a-input v-decorator="['name']" initialValue="record.name" @input="record.name = $event.target.record.name"/>

问题 2。我将“v-decorator”替换为 v-model="record.name" 并且它可以工作,数据在 a-input 内可用于编辑,但是一旦提交表单,值不会传递给“ this.form”函数,因为输入的名称不存在。这是我完整的html代码

<a-input v-model="record.name" name="name" @input="record.name = $event.target.record.name"/>

可能的答案

1. how to set the "initial value" inside v-decorator for updating the value?
2. how to set "name" of input when using v-model which is already populated with record from database?

这里有人了解 vue js 中的 ant 设计吗?我需要帮助

【问题讨论】:

    标签: vue.js antd ant-design-pro


    【解决方案1】:

    你可以在v-decorator的选项对象中使用initialValue

                     <a-form-item>
                        <a-input
                            v-decorator="[
                              'name',
    
                              { initialValue: user.email, rules: [{ type: 'name', required: true, message: 'Please use a valid name.' }] },
                            ]"
                            placeholder="Name"
                        >
                            <a-icon slot="prefix" type="mail" style="color:rgba(0,0,0,.25)" />
                        </a-input>
                        </a-form-item>
    

    【讨论】:

    • 这对我不起作用:(
    猜你喜欢
    • 2019-04-30
    • 1970-01-01
    • 2018-11-02
    • 2021-12-11
    • 1970-01-01
    • 2016-11-12
    • 2019-01-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多