前端效果 登入界面

文章目录

效果展示:

代码:

vue 复制代码
<template>
  <div class="login">
    <div class="section-1">
      <div class="card" @mouseover="activeCard = 1" @mouseleave="activeCard = 0" @click="islogin = !islogin">
        <div class="container" :class="{ active: activeCard === 1 }">
          <div class="title-info">
            <div class="title">{{ '登入' }}</div>
            <div class="info">{{ '登入网易云音乐' }}</div>
          </div>
        </div>
      </div>
      <div class="card" @mouseover="activeCard = 2" @mouseleave="activeCard = 0" @click="goTo('about')">
        <div class="container" :class="{ active: activeCard === 2 }">
          <div class="title-info">
            <div class="title">{{ '跳过' }}</div>
            <div class="info">{{ '跳过登入进入' }}</div>
          </div>
        </div>
      </div>
    </div>
    <div class="section-2" v-if="islogin">
      <p style="font-size: 35px; font-weight:600; text-align: center;"> 登入</p>
      <el-input class="input" v-model="form.username" placeholder="Please input username" />
      <el-input
        class="input"
        v-model="form.password"
        type="password"
        placeholder="Please input password"
        show-password
      />
      <div class="input" style="display: flex; justify-content: center;">
        <el-button type="primary"  style= "width: 200px; " @click="onSubmit">登入</el-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted, onUnmounted } from 'vue'
import { useRouter } from 'vue-router'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

const activeCard = ref(0)
const router = useRouter()
const islogin = ref(false)

const form = reactive({
  username : '',
  password : '',
});

const onSubmit = () => {
  console.log(form.username, form.password)
}

NProgress.start()

onMounted(() => {
  NProgress.done()
})

onUnmounted(() => {
  NProgress.remove() // 如果需要在组件卸载时清除进度条,可以调用这个方法
})

async function goTo(path) {
  await router.push({ path: `/${path}` })
  console.log('hello')
}
</script>

<style lang="scss" scoped>
.login {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  height: calc(100vh - 192px);
}

.section-1 {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
}


.section-2 {
  background-color: #eaeffd;
  justify-content: center;
  margin-left: 100px;
  width: 500px;
  height: 312px;
  padding-left: 80px;
  padding-right: 80px;
  padding-top: 10px;
}

.section-2 .input {
  margin-top: 30px;
  height: 40px
}

.card {
  cursor: pointer;
  margin-top: 14px;
  margin-bottom: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #eaeffd;
  border-radius: 8px;
  height: 128px;
  width: 300px;
  transition: all 0.3s;
  padding-left: 22px;
  box-sizing: border-box;

  .active {
    .title-info {
      transform: translateX(-8px);
    }
  }

  .container {
    display: rgb(234, 239, 253);
    // justify-content: space-around;
    align-items: center;

    color: #335eea;
  }

  .title-info {
    transition: all 0.3s;
  }

  .title {
    font-size: 24px;
    font-weight: 600;
  }

  .info {
    margin-top: 2px;
    font-size: 14px;
    color: rgba(51, 94, 234, 0.78);
  }
}
</style>
相关推荐
Martin -Tang1 分钟前
vite和webpack的区别
前端·webpack·node.js·vite
迷途小码农零零发2 分钟前
解锁微前端的优秀库
前端
王解1 小时前
webpack loader全解析,从入门到精通(10)
前端·webpack·node.js
老码沉思录1 小时前
写给初学者的React Native 全栈开发实战班
javascript·react native·react.js
我不当帕鲁谁当帕鲁1 小时前
arcgis for js实现FeatureLayer图层弹窗展示所有field字段
前端·javascript·arcgis
那一抹阳光多灿烂1 小时前
工程化实战内功修炼测试题
前端·javascript
放逐者-保持本心,方可放逐2 小时前
微信小程序=》基础=》常见问题=》性能总结
前端·微信小程序·小程序·前端框架
毋若成4 小时前
前端三大组件之CSS,三大选择器,游戏网页仿写
前端·css
红中马喽4 小时前
JS学习日记(webAPI—DOM)
开发语言·前端·javascript·笔记·vscode·学习
Black蜡笔小新5 小时前
网页直播/点播播放器EasyPlayer.js播放器OffscreenCanvas这个特性是否需要特殊的环境和硬件支持
前端·javascript·html