Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to rewind Vue form forms

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report