国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

node.js|vue.js|jquery|angularjs|React|json|js教程|

服務(wù)器之家 - 編程語言 - JavaScript - vue.js - vue實現(xiàn)登錄注冊模板的示例代碼

vue實現(xiàn)登錄注冊模板的示例代碼

2022-02-22 16:11~李疆 vue.js

這篇文章主要介紹了vue實現(xiàn)登錄注冊模板的示例代碼,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

模板1: 

vue實現(xiàn)登錄注冊模板的示例代碼

login.vue

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<template>
    <p class="login">
        <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="登錄" name="first">
                <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                    <el-form-item label="名稱" prop="name"><el-input v-model="ruleForm.name"></el-input></el-form-item>
 
                    <el-form-item label="密碼" prop="pass"><el-input type="password" v-model="ruleForm.pass" auto-complete="off"></el-input></el-form-item>
 
                    <el-form-item>
                        <el-button type="primary" @click="submitForm('ruleForm')">登錄</el-button>
 
                        <el-button @click="resetForm('ruleForm')">重置</el-button>
                    </el-form-item>
                </el-form>
            </el-tab-pane>
 
            <el-tab-pane label="注冊" name="second">
                <register></register>
            </el-tab-pane>
        </el-tabs>
    </p>
</template>
 
<script>
import register from '@/components/register';
 
export default {
    data() {
        var validatePass = (rule, value, callback) => {
            if (value === '') {
                callback(new Error('請輸入密碼'));
            } else {
                if (this.ruleForm.checkPass !== '') {
                    this.$refs.ruleForm.validateField('checkPass');
                }
 
                callback();
            }
        };
 
        return {
            activeName: 'first',
            ruleForm: {
                name: '',
                pass: '',
                checkPass: ''
            },
            rules: {
                name: [{ required: true, message: '請輸入您的名稱', trigger: 'blur' }, { min: 2, max: 5, message: '長度在 2 到 5 個字符', trigger: 'blur' }],
                pass: [{ required: true, validator: validatePass, trigger: 'blur' }]
            }
        };
    },
 
    methods: {
        //選項卡切換
        handleClick(tab, event) {},
        //重置表單
        resetForm(formName) {
            this.$refs[formName].resetFields();
        },
        //提交表單
        submitForm(formName) {
            this.$refs[formName].validate(valid => {
                if (valid) {
                    this.$message({
                        type: 'success',
                        message: '登錄成功'
                    });
                    this.$router.push('home');
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        }
    },
    components: {
        register
    }
};
</script>
 
<style lang="scss">
.login {
    width: 400px;
    margin: 0 auto;
}
 
.el-tabsitem {
    text-align: center;
    width: 60px;
}
</style>

register.vue

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//register組件
 
<template>
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="用戶名" prop="name"><el-input v-model="ruleForm.name"></el-input></el-form-item>
        <el-form-item label="密碼" prop="pass"><el-input type="password" v-model="ruleForm.pass" auto-complete="off"></el-input></el-form-item>
        <el-form-item label="確認(rèn)密碼" prop="checkPass"><el-input type="password" v-model="ruleForm.checkPass" auto-complete="off"></el-input></el-form-item>
        <el-form-item>
            <el-button type="primary" @click="submitForm('ruleForm')">注冊</el-button>
            <el-button @click="resetForm('ruleForm')">重置</el-button>
        </el-form-item>
    </el-form>
</template>
 
<script>
export default {
    data() {
        var validatePass = (rule, value, callback) => {
            if (value === '') {
                callback(new Error('請輸入密碼'));
            } else {
                if (this.ruleForm.checkPass !== '') {
                    this.$refs.ruleForm.validateField('checkPass');
                }
                callback();
            }
        };
 
        var validatePass2 = (rule, value, callback) => {
            if (value === '') {
                callback(new Error('請再次輸入密碼'));
            } else if (value !== this.ruleForm.pass) {
                callback(new Error('兩次輸入密碼不一致!'));
            } else {
                callback();
            }
        };
 
        return {
            activeName: 'second',
            ruleForm: {
                name: '',
                pass: '',
                checkPass: ''
            },
            rules: {
                name: [{ required: true, message: '請輸入您的名稱', trigger: 'blur' }, { min: 2, max: 5, message: '長度在 2 到 5 個字符', trigger: 'blur' }],
                pass: [{ required: true, validator: validatePass, trigger: 'blur' }],
                checkPass: [{ required: true, validator: validatePass2, trigger: 'blur' }]
            }
        };
    },
 
    methods: {
        submitForm(formName) {
            this.$refs[formName].validate(valid => {
                if (valid) {
                    this.$message({
                        type: 'success',
                        message: '注冊成功'
                    });
                    // this.activeName: 'first',
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
 
        resetForm(formName) {
            this.$refs[formName].resetFields();
        }
    }
};
</script>

效果圖

vue實現(xiàn)登錄注冊模板的示例代碼

vue實現(xiàn)登錄注冊模板的示例代碼

模板2:

vue實現(xiàn)登錄注冊模板的示例代碼

vue實現(xiàn)登錄注冊模板的示例代碼

login.vue

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<template>
  <el-row type="flex" justify="center">
   <el-form ref="formData" :model="formData" :rules="rules" label-width="80px" @keyup.enter.native="login()">
    <el-form-item prop="userName" label="用戶名"><el-input v-model="formData.userName" placeholder="請輸入用戶名" prefix-icon="icon-login_user" clearable></el-input></el-form-item>
    <el-form-item prop="password" label="密碼"><el-input v-model="formData.password" placeholder="請輸入密碼" type="password" prefix-icon="icon-login_pwd" clearable></el-input></el-form-item>
    </el-form-item>
    <el-form-item><el-button type="primary" class="btn" @click="login('formData')" icon="el-icon-upload">登錄</el-button>
     <el-button @click="resetForm('formData')">重置</el-button></el-form-item></el-form-item>
     <router-link to="register">沒有密碼?注冊</router-link>
   </el-form>
  </el-row>
</template>
<script>
export default {
 data() {
  return {
   formData: {
    userName: '',
    password: ''
   },
   rules: {
    userName: [{ required: true, message: '用戶名不能為空', trigger: 'blur' }],
    password: [{ required: true, message: '密碼不能為空', trigger: 'blur' }]
   }
  };
 },
 methods: {
  login(formName) {
 
    this.$refs[formName].validate(valid => {
                if (valid) {
                    this.$message({
                        type: 'success',
                        message: '登錄成功'
          });
           this.$router.push({name:'home'});
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
  },
   resetForm(formName) {
            this.$refs[formName].resetFields();
        }
 }
};
</script>

register.vue

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<template>
  <el-row type="flex" justify="center">
   <el-form ref="formData" :model="formData" :rules="rules" label-width="80px" @keyup.enter.native="register()">
    <el-form-item prop="userName" label="用戶名"><el-input v-model="formData.userName" placeholder="請輸入用戶名" prefix-icon="icon-login_user" clearable></el-input></el-form-item>
    <el-form-item prop="password" label="密碼"><el-input v-model="formData.password" placeholder="請輸入密碼" type="password" prefix-icon="icon-login_pwd" clearable></el-input></el-form-item>
    <el-form-item prop="cheackPassword" label="確認(rèn)密碼"><el-input v-model="formData.cheackPassword" placeholder="再次輸入密碼" type="password" prefix-icon="icon-login_pwd" clearable></el-input></el-form-item>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="register('formData')" icon="el-icon-upload">注冊</el-button>
      <el-button @click="resetForm('formData')">重置</el-button></el-form-item>
     <router-link to="login">已有密碼?登錄</router-link>
 
   </el-form>
  </el-row>
</template>
<script>
export default {
 data() {
   var validatePass = (rule, value, callback) => {
            if (value === '') {
                callback(new Error('請再次輸入密碼'));
            } else if (value !== this.formData.password) {
                callback(new Error('兩次輸入密碼不一致!'));
            } else {
                callback();
            }
        };
 
  return {
   formData: {
    userName: '',
    password: '',
    cheackPassword:''
   },
   rules: {
    userName: [{ required: true, message: '用戶名不能為空', trigger: 'blur' }],
    password: [{ required: true, message: '密碼不能為空', trigger: 'blur' }],
    cheackPassword: [{ required: true, validator: validatePass, trigger: 'blur' }]
 
   }
  };
 },
 methods: {
  register(formName) {
   this.$refs[formName].validate(valid => {
                if (valid) {
                    this.$message({
                        type: 'success',
                        message: '注冊成功'
          });
           this.$router.push({name:'login'});
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
  },
  resetForm(formName) {
            this.$refs[formName].resetFields();
        }
 
 }
};
</script>

效果圖

vue實現(xiàn)登錄注冊模板的示例代碼

vue實現(xiàn)登錄注冊模板的示例代碼

到此這篇關(guān)于vue實現(xiàn)登錄注冊模板的示例代碼的文章就介紹到這了,更多相關(guān)vue 登錄注冊模板內(nèi)容請搜索服務(wù)器之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持服務(wù)器之家!

原文鏈接:https://blog.csdn.net/qq_40323256/article/details/103020807

延伸 · 閱讀

精彩推薦
  • vue.js用vite搭建vue3應(yīng)用的實現(xiàn)方法

    用vite搭建vue3應(yīng)用的實現(xiàn)方法

    這篇文章主要介紹了用vite搭建vue3應(yīng)用的實現(xiàn)方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下...

    Asiter7912022-01-22
  • vue.jsVue2.x-使用防抖以及節(jié)流的示例

    Vue2.x-使用防抖以及節(jié)流的示例

    這篇文章主要介紹了Vue2.x-使用防抖以及節(jié)流的示例,幫助大家更好的理解和學(xué)習(xí)使用vue框架,感興趣的朋友可以了解下...

    Kyara6372022-01-25
  • vue.js梳理一下vue中的生命周期

    梳理一下vue中的生命周期

    看過很多人講vue的生命周期,但總是被繞的云里霧里,尤其是自學(xué)的同學(xué),可能js的基礎(chǔ)也不是太牢固,聽起來更是吃力,那我就已個人之淺見,以大白話...

    CRMEB技術(shù)團隊7992021-12-22
  • vue.jsVue多選列表組件深入詳解

    Vue多選列表組件深入詳解

    這篇文章主要介紹了Vue多選列表組件深入詳解,這個是vue的基本組件,有需要的同學(xué)可以研究下...

    yukiwu6752022-01-25
  • vue.jsVue2.x 項目性能優(yōu)化之代碼優(yōu)化的實現(xiàn)

    Vue2.x 項目性能優(yōu)化之代碼優(yōu)化的實現(xiàn)

    這篇文章主要介紹了Vue2.x 項目性能優(yōu)化之代碼優(yōu)化的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋...

    優(yōu)小U9632022-02-21
  • vue.jsVue中引入svg圖標(biāo)的兩種方式

    Vue中引入svg圖標(biāo)的兩種方式

    這篇文章主要給大家介紹了關(guān)于Vue中引入svg圖標(biāo)的兩種方式,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的...

    十里不故夢10222021-12-31
  • vue.jsVue項目中實現(xiàn)帶參跳轉(zhuǎn)功能

    Vue項目中實現(xiàn)帶參跳轉(zhuǎn)功能

    最近做了一個手機端系統(tǒng),其中遇到了父頁面需要攜帶參數(shù)跳轉(zhuǎn)至子頁面的問題,現(xiàn)已解決,下面分享一下實現(xiàn)過程,感興趣的朋友一起看看吧...

    YiluRen丶4302022-03-03
  • vue.js詳解vue 表單綁定與組件

    詳解vue 表單綁定與組件

    這篇文章主要介紹了vue 表單綁定與組件的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)使用vue框架,感興趣的朋友可以了解下...

    Latteitcjz6432022-02-12
主站蜘蛛池模板: 午夜午夜精品一区二区三区文 | 亚洲激情av | jav久久亚洲欧美精品 | 国内精品久久久久久 | 在线看国产 | 国产精品精品 | 羞羞av| 久久久精品一区二区 | 在线成人av | 日日操狠狠操 | 日比毛片 | 国内精品久久久久 | 精品在线| 欧洲精品在线观看 | 久久久久国产一区二区三区四区 | 久久精品中文 | 精品一区二区久久久久黄大片 | 国产999精品久久久久久 | 欧美亚洲天堂 | 群p在线观看| 一区二区三区在线看 | 三级电影网址 | 午夜激情免费看 | 国产高清在线精品一区二区三区 | 久久中文视频 | 日韩一区二区三区在线观看 | 久久夜色精品国产 | 精品在线一区二区三区 | 国产最新视频 | 成人综合在线观看 | 午夜精品福利在线观看 | 国产精品一区二区三区免费 | 国产欧美日韩精品一区 | 中国大陆一级毛片 | 国产欧美精品一区二区 | 国产成人免费视频网站视频社区 | 久久久国产一区二区三区 | 久草在线免费福利资源 | 欧美性猛交一区二区三区精品 | 国产精品美女久久久久久久网站 | 色婷婷综合网 |