In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "Vue3+Element+Ts how to achieve the basic search reset and other functions of the form", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Vue3+Element+Ts how to achieve the form of the basic search reset and other functions"!
Code structure:
Write method 1 (recommended):
Import {ref, reactive} from 'vue'import type {ElForm} from' element-plus'const myform = ref () const formData = reactive ({name:', subject:', grade:'}) / / find const submitForm = () = > {const {name, subject, grade} = formData console.log (name, subject Grade)} / / reset const submitReset = () = > {myform.value?.resetFields ()} Check for reset .mysearch {padding: 20px }
Writing method 2:
Check for reset import {defineComponent, reactive, ref} from 'vue'import {ElForm} from' element-plus'export default defineComponent ({setup () {const formData = reactive ({name:', subject:', grade:'}) const myform = ref () / / find const submitForm = () = > {const {name Subject, grade} = formData console.log (name, subject, grade)} / / reset const submitReset = () = > {myform.value?.resetFields ()} return {formData, myform, submitForm, submitReset}}) .mysearch {padding: 20px } difference:
The first method of writing is from top to bottom, which is JS, HTML and Css, which is similar to React, and the logic is clear.
The first method of writing is from top to bottom, which is HTML, JS and Css, similar to the previous Vue2.
The format of method 1 does not need to export data,methods and other contents, which saves the amount of code.
Key points:
1. Prop is not written in the code of Element Plus's official website Demo.
In order to achieve responsive data, you need to bind it yourself when you write.
2. Ref using el-form needs to introduce ElForm
Import {ElForm} from 'element-plus'const myform = ref () so far, I believe you have a deeper understanding of "how to achieve the basic search reset function of the form". You might as well do it in practice! here is the website, more related content can enter the relevant channels to query, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.