Skip to content
This repository was archived by the owner on May 12, 2020. It is now read-only.

Commit 5a76c62

Browse files
committed
feat(Login): form validation when user submit form
1 parent b95664a commit 5a76c62

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

src/pages/Login/index.vue

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
label-position="right"
66
:model="userInfo"
77
:rules="rules"
8+
ref="login"
9+
status-icon
10+
@keyup.enter.native="onSubmit"
811
>
912
<h1 class="login__form__title">admin template</h1>
1013
<el-form-item prop="username">
1114
<el-input
12-
v-model="userInfo.name"
15+
v-model="userInfo.username"
1316
placeholder="请输入用户名"
17+
clearable
1418
>
1519
<i slot="prefix" class="el-icon-service"></i>
1620
</el-input>
@@ -19,6 +23,8 @@
1923
<el-input
2024
v-model="userInfo.password"
2125
placeholder="请输入密码"
26+
type="password"
27+
clearable
2228
>
2329
<i slot="prefix" class="el-icon-goods"></i>
2430
</el-input>
@@ -45,7 +51,7 @@ export default {
4551
data () {
4652
return {
4753
userInfo: {
48-
name: '',
54+
username: '',
4955
password: ''
5056
},
5157
rules
@@ -60,9 +66,16 @@ export default {
6066
6167
methods: {
6268
onSubmit () {
63-
// if (!this.userInfo.username || !this.userInfo.password) return
64-
console.info('activate submit')
65-
this.$router.push('/')
69+
this.$refs.login.validate(isValid => {
70+
if (!isValid) return
71+
this.loading = true
72+
// this.pushLogin({
73+
// userInfo: this.loginForm,
74+
// replace: this.$router.replace.bind(this.$router)
75+
// })
76+
// .finally(() => { this.loading = false })
77+
this.$router.push('/')
78+
})
6679
}
6780
}
6881
}

0 commit comments

Comments
 (0)