Get the App
SLTechnology News&Howtos  ›  Development  › 

How to rewind Vue form forms

Shulou Source: shulou.com Published: 2022-06-01 07:03:59 09月21日 Update

This article introduces the knowledge of "how to reproduce Vue form forms". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

How to rewind form forms

In Ant Design Of Vue (ant-design-vue), instead of using v-model, you will be prompted to use v-decorator directly.

avatar

Upload

For echo, use this.form.setFieldsValue directly

This.form.setFieldsValue ({"username": ['username_ddddd'], "nickname": [' nickname_ddddd']}); / / set the value

This.form.setFieldsValue ({"username": 'username_ddddd', "nickname":' nickname_ddddd'}); / / set the value

This.form.getFieldsValue (); / / get all values

This.form.getFieldsValue (['username','nickname']); / / get a value

This.form.resetFields (); / / reset form values

This.form.validateFields ((err,fieldsValue) = > {/ / verify all values

If (! err) {

Console.log (fieldsValue); / / get data {nickname: "actual value", username: "actual value"}

} else {

Console.log (err)

}

});

This.form.validateFields (['nickname'], (err,fieldsValue) = > {/ / verify a value

If (! err) {

Console.log (fieldsValue); / / get data {nickname: "actual value"}

} else {

Console.log (err)

}

});

It's important to note that sometimes a warning occurs on the console, that is, when you render a component, you give me a set value for this form about You cannot set a form field before rendering a field associated with the value

FormData: {

Handler: function (val) {

Const {name, note} = val

This.$nextTick () = > {

If (this.type = = 'edit') {

This.form.setFieldsValue ({

Name

Note

})

}

})

}

Deep: true

}

2. The cross-domain problem of x-request-with request headers will occur when upload components are uploaded

You need to set x-request-with to null for the headers of the component

Headers: {

'Xmuri RequestedMutual Withballs: null

}

This is the end of the content of "how to rewind Vue form forms". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Forms actual components content data time more knowledge practicality learning and then dilemmas pictures that is stores situations consoles articles sometimes Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Linux Shulou Tech Info NVidia OPPO Reno