1. Build basic styles through ElementUIIf you don’t know ElementUI, please visit the official website https://element.eleme.cn/#/zh-CN to get a basic understanding of ElementUI. 1.1 Use of ElementUI First install ElementUI in the project through the command npm i element-ui S 1.2 Then find the from form on the official website and then you can do the basic layout So here is the framework I have written <el-form label-position="top" label-width="100px" class="demo-ruleForm" :rules='rules' :model='rulesForm' status-icon ref='ruleForm' > <el-form-item label="username" prop="name"> <el-input type="text" v-model="rulesForm.name"></el-input> </el-form-item> <el-form-item label="password" prop="password"> <el-input type="password" v-model="rulesForm.password"></el-input> </el-form-item> <el-form-item> <el-button type="primary" @click="submitForm('ruleForm')">Submit</el-button> <el-button>Reset</el-button> </el-form-item> </el-form> The effects of these codes Some ElementUI properties are used here, so I won’t explain them here. They are all on the official website. So I’ll put some screenshots for you to check these properties. Then the rules and model are used together to make some input boxes to enter rules Then bind these two rules to the account and password box ElementUI layout is just a few clicks 2. Click the Submit button to pass the contents of the account and password box to the background dataWe can better get the attributes in the tag through ref The following is the method to pass the content in the input box to the background methods: { submitForm(fromName){ this.$refs[fromName].validate((valid)=>{ if(valid){ //If the check passes, send the username and password to the backend login({ name:this.rulesForm.name, password:this.rulesForm.password }).then((data)=>{ if(data.code==0){ localStorage.setItem('token',data.data.token) window.location.href='/' } if(data.code==1){ this.$message.error(data.message) } }) }else{ console.log('error submit!!') return false } }) } } One of them is login, which is a method obtained by encapsulating an interface of the backend This method is bound to the submit button Then we enter the existing account password and click the submit button to log in. Then we render some login information SummarizeThere are two steps to achieve a login effect: first use ElementUI to build the corresponding style --- "Click the submit button to pass the content in the account and password box to the background data This is the end of this article about the example of using vue ElementUI's from form to achieve login effects. For more relevant vue Element from form login content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Complete steps for using Nginx+Tomcat for load balancing under Windows
>>: Analysis of the difference between Mysql InnoDB and MyISAM
Table of contents I. Overview 2. pt-archiver main...
Table of contents 1. Add packaging command 2. Run...
Here are two ways to install MySQL under Linux: y...
1. Error details Once when manually performing a ...
The <abbr> and <acronym> tags represen...
Fault site: Log in to the MySQL server and get th...
How to define complex components (class component...
Recently, the business side reported that some us...
Table of contents 1. Concepts related to stored p...
First of all, we know that this effect should be ...
Table of contents Preface Implementation ideas Im...
Table of contents Docker Installation Nvidia-dock...
tomcat server configuration When everyone is lear...
Find information Some methods found on the Intern...
#String concatenation concat(s1,s2); concatenate ...