最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue實現(xiàn)簡單登錄界面

 更新時間:2022年06月19日 06:43:52   作者:5210丫  
這篇文章主要為大家詳細(xì)介紹了Vue實現(xiàn)簡單登錄界面,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了Vue實現(xiàn)簡單登錄界面的具體代碼,供大家參考,具體內(nèi)容如下

實現(xiàn):

  • 界面實現(xiàn)
  • 表單規(guī)則校驗
  • 結(jié)合后臺 api 校驗
  • 提示消息

App.vue

<template>
? <div id="app">
<!--路由占位符 -->
? ?<router-view></router-view>
? </div>
</template>
<script>
export default {
? name: 'app'
}
</script>
<style>
</style>

登錄頁面login.vue

<template>
?
? <div class="login_container">
?
? ? <div class="login_box">
? ? ? <div class="ava_box">
? ? ? ? <img src="../assets/logo.png" />
? ? ? </div>
? ? ? <!-- 賬號 -->
? ? ? <el-form :model="loginForm" ref="loginFormRef" :rules="loginFormRules" label-width="0px" class="login_form">
? ? ? ? <el-form-item prop="username">
? ? ? ? ? <el-input ?v-model="loginForm.username" ?prefix-icon="el-icon-user-solid"></el-input>
? ? ? ? </el-form-item>
? ? ? ? <!-- 密碼 -->
? ? ? ? <el-form-item prop="password">
? ? ? ? ? <el-input ? v-model="loginForm.password" show-password="true" prefix-icon="el-icon-lock"></el-input>
? ? ? ? </el-form-item>
?
? ? ? ? <!-- 按鈕 -->
? ? ? ? <el-form-item class="btns">
? ? ? ? ? <el-button type="primary" @click="login" round>登錄</el-button>
? ? ? ? ? <!-- ? ? ?<el-button type="success" round>成功按鈕</el-button> -->
? ? ? ? ? <el-button type="info" @click="resetLoginForm" round>重置</el-button>
? ? ? ? </el-form-item>
? ? ? </el-form>
?
? ? </div>
?
? </div>
</template>
?
<script>
? export default {
? ? data(){
? ? ? return{
? ? ? ? // 表單數(shù)據(jù)綁定
? ? ? ? loginForm: {
? ? ? ? ? username: 'admin',
? ? ? ? ? password: '123456'
? ? ? ? },
? ? ? ? // 檢驗規(guī)則
? ? ? ? loginFormRules: {
? ? ? ? ? username: [
? ? ? ? ? ? {required: true,message: '請輸入用戶名',trigger: 'blur'},
? ? ? ? ? ? { min: 3, max: 8, message: '長度在 3 到 8 個字符', trigger: 'blur' }
? ? ? ? ? ],
? ? ? ? ? password: [
? ? ? ? ? ? ? {required: true,message: '密碼不能為空',trigger: 'blur'},
? ? ? ? ? ? ? ?{ min: 6, max: 12, message: '長度在 6 到 12 個字符', trigger: 'blur' }
? ? ? ? ? ]
?
? ? ? ? }
? ? ? }
? ? },
? ? methods:{
? ? ? resetLoginForm(){
? ? ? ? this.$refs.loginFormRef.resetFields();
? ? ? },
? ? ? login(){
? ? ? ? this.$refs.loginFormRef.validate(async valid=>{
? ? ? ? ? ? console.log(valid);
? ? ? ? ? ? if(!valid) return;
? ? ? ? ? ? ?const {data: res}= await this.$http.post('login',this.loginForm);
? ? ? ? ? ? ?console.log(res)
? ? ? ? ? ? ?if(res.meta.status!=200) return this.$message.error('登錄失敗')
? ? ? ? ? ? this.$message.success('登錄成功')
?
? ? ? ? });
? ? ? }
? ? }
? }
</script>
<style lang="less" scoped>
?
? .login_container {
? ? background-color: #2b4b6b;
? ? height: 100%;
? }
?
? .login_box {
? ? height: 300px;
? ? width: 450px;
? ? background-color: #fff;
? ? border-radius: 3px;
? ? position: absolute;
? ? left: 50%;
? ? top: 50%;
? ? // 橫軸,縱軸
? ? transform: translate(-50%, -50%);
?
? ? .ava_box {
? ? ? height: 130px;
? ? ? width: 130px;
? ? ? border: 1px solid #eee;
? ? ? border-radius: 50%;
? ? ? padding: 10px;
? ? ? box-shadow: 0 0 10px #ddd;
? ? ? position: absolute;
? ? ? left: 50%;
? ? ? transform: translate(-50%, -50%);
? ? ? background-color: #fff;
?
? ? ? img {
? ? ? ? width: 100%;
? ? ? ? height: 100%;
? ? ? ? border-radius: 50%;
? ? ? ? background-color: #eee;
? ? ? }
? ? }
? ? .btns{
? ? ? display: flex;
? ? ? justify-content: flex-end;
?
? ? }
? ? .login_form{
? ? ? position: absolute;
? ? ? bottom: 0px;
? ? ? width: 100%;
? ? ? padding: 0 20px;
? ? ? box-sizing: border-box;
?
? ? }
? }
</style>

element.js

import Vue from 'vue'
import { Button, Form, FormItem, Input,Message } from 'element-ui'
Vue.prototype.$message=Message
Vue.use(Button)
Vue.use(Form)
Vue.use(FormItem)
Vue.use(Input)
Vue.use(Message)

main.js

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/css/global.css'
import axios from 'axios'
Vue.config.productionTip = false
axios.defaults.baseURL=''
Vue.prototype.$http=axios
new Vue({
? router,
? render: h => h(App)
}).$mount('#app')

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • el-table實現(xiàn)轉(zhuǎn)置表格的示例代碼(行列互換)

    el-table實現(xiàn)轉(zhuǎn)置表格的示例代碼(行列互換)

    這篇文章主要介紹了el-table實現(xiàn)轉(zhuǎn)置表格的示例代碼(行列互換),本文結(jié)合示例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧
    2024-02-02
  • vue-cli 3.0 引入mint-ui報錯問題及解決

    vue-cli 3.0 引入mint-ui報錯問題及解決

    這篇文章主要介紹了vue-cli 3.0 引入mint-ui報錯問題及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-05-05
  • vue中動態(tài)修改animation效果無效問題詳情

    vue中動態(tài)修改animation效果無效問題詳情

    這篇文章主要介紹了vue中動態(tài)修改animation效果無效問題詳情,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價值,需要的小伙伴可以參考一下
    2022-06-06
  • vue點擊右鍵出現(xiàn)自定義操作菜單實現(xiàn)代碼

    vue點擊右鍵出現(xiàn)自定義操作菜單實現(xiàn)代碼

    這篇文章主要給大家介紹了關(guān)于vue點擊右鍵出現(xiàn)自定義操作菜單實現(xiàn)的相關(guān)資料,在網(wǎng)頁中我們也希望可以像桌面軟件一樣,點擊右鍵后出現(xiàn)操作菜單,對選中的數(shù)據(jù)項進(jìn)行相應(yīng)的操作,需要的朋友可以參考下
    2023-08-08
  • vue集成百度UEditor富文本編輯器使用教程

    vue集成百度UEditor富文本編輯器使用教程

    這篇文章主要為大家詳細(xì)介紹了vue集成百度UEditor富文本編輯器的使用教程,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-09-09
  • vue封裝一個彈幕組件詳解

    vue封裝一個彈幕組件詳解

    這篇文章主要介紹了vue封裝一個彈幕組件詳解,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價值,需要的小伙可以參考一下
    2022-08-08
  • Vue配合iView實現(xiàn)省市二級聯(lián)動的示例代碼

    Vue配合iView實現(xiàn)省市二級聯(lián)動的示例代碼

    本篇文章主要介紹了Vue配合iView實現(xiàn)省市二級聯(lián)動的示例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-07-07
  • vue 父組件獲取子組件里面的data數(shù)據(jù)(實現(xiàn)步驟)

    vue 父組件獲取子組件里面的data數(shù)據(jù)(實現(xiàn)步驟)

    在Vue中,父組件可以通過`ref`引用子組件,并通過`$refs`屬性來訪問子組件的數(shù)據(jù),下面分步驟給大家介紹vue 父組件獲取子組件里面的data數(shù)據(jù),感興趣的朋友一起看看吧
    2024-06-06
  • ElementUI日期選擇器時間選擇范圍限制的實現(xiàn)

    ElementUI日期選擇器時間選擇范圍限制的實現(xiàn)

    在日常開發(fā)中,我們會遇到一些情況,限制日期的范圍的選擇,本文就詳細(xì)的介紹了ElementUI日期選擇器時間選擇范圍限制的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),感興趣的可以了解一下
    2022-04-04
  • vue3中給數(shù)組賦值丟失響應(yīng)式的解決

    vue3中給數(shù)組賦值丟失響應(yīng)式的解決

    這篇文章主要介紹了vue3中給數(shù)組賦值丟失響應(yīng)式的解決方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-04-04

最新評論

鹿泉市| 沂南县| 沾化县| 呼和浩特市| 临海市| 云梦县| 璧山县| 吴江市| 额敏县| 噶尔县| 尉犁县| 大悟县| 朝阳市| 水富县| 南乐县| 邮箱| 聊城市| 五寨县| 东明县| 福贡县| 舒城县| 宜阳县| 曲阳县| 内丘县| 浦东新区| 永胜县| 工布江达县| 华容县| 马山县| 惠东县| 高陵县| 汶川县| 曲松县| 临江市| 垣曲县| 镇沅| 寿阳县| 全椒县| 崇明县| 阜康市| 海晏县|