使用Vue写一个登录页面

使用Vue写一个登录页面上一博客讲到构建了一个vue项目,现在在那个项目之上实现一个登录页面。1.构建项目的目录2.App.vue<template><divid="app"><router-view/></div></template><script>exportdefault{

大家好,又见面了,我是你们的朋友全栈君。

上一博客讲到构建了一个vue项目,现在在那个项目之上实现一个登录页面。

1.构建项目的目录

使用Vue写一个登录页面

2.App.vue

<template>
  <div id="app">
    <router-view/>
  </div>
</template>

<script>
  export default {
    name: 'App'
  }
</script>

main.js

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

//自己写的样式
import './style/theme.css'
import './style/characters.css'

// 注册element-ui
Vue.use(ElementUI)

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})

theme.css

body {
  padding: 0;
  margin:0;
  font-family: "Microsoft YaHei UI Light";
}

.outer_label {
  position: relative;
  left: 0;
  top: 0;
  width: 100%;
  height: 220px;
  background: -webkit-linear-gradient(left, #000099, #2154FA); /* Safari 5.1 - 6.0 */
  background: -o-linear-gradient(right, #000099, #2154FA); /* Opera 11.1 - 12.0 */
  background: -moz-linear-gradient(right, #000099, #2154FA); /* Firefox 3.6 - 15 */
  background: linear-gradient(to right, #000099 , #2154FA); /* 标准的语法 */
  /*background-color: #000099;*/
  text-align: center;
  filter: brightness(1.4);
}
.inner_label {
  position: absolute;
  left:0;
  right: 0;
  bottom: 0;
  top:0;
  margin: auto;
  height: 50px;
}
.qxs-icon {
  height: 40px;
  width: 90%;
  margin-bottom: 5px;
  padding-left: 10%;
  border: 0;
  border-bottom: solid 1px lavender;
}

character.css

.text-size12px{
  font-size: 12px;
}
.text-size14px{
  font-size: 14px;
}
.text-size16px{
  font-size: 16px;
}
.float-right {
  float: right;
}
.item-color {
  color: #848487;
}

index.js

import Vue from 'vue'
import Router from 'vue-router'
// import HelloWorld from '@/components/HelloWorld'
import Login from '@/components/login/Login'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Login',
      component: Login
    }
  ]
})

Login.vue

<template>
  <div>
    <div class="outer_label">
      <img class="inner_label login_logo" src="../../assets/logo.png">
    </div>
    <div class="login_form">
      <input type="text"  class="qxs-ic_user qxs-icon"  placeholder="用户名" v-model="userName">
      <input type="text"  class="qxs-ic_password qxs-icon"  placeholder="密码" v-model="password">
      <!--<button class="login_btn el-button el-button&#45;&#45;primary is-round" type="primary" round>登录</button>-->
      <el-button class="login_btn" @click.native="login" type="primary" round :loading="isBtnLoading">登录</el-button>
      <div style="margin-top: 10px">
        <span style="color: #000099;" @click="login">司机账号登陆</span><span style="float: right;color: #A9A9AB">忘记密码?</span>
      </div>
    </div>
  </div>
</template>



<script>
//  import { userLogin } from '../../api/api';

  export default {
    data() {
      return {
        userName: '',
        password: '',
        isBtnLoading: false
      }
    },
    created () {
      if(JSON.parse( localStorage.getItem('user')) && JSON.parse( localStorage.getItem('user')).userName){
        this.userName = JSON.parse( localStorage.getItem('user')).userName;
        this.password = JSON.parse( localStorage.getItem('user')).password;
      }
    },
    computed: {
      btnText() {
        if (this.isBtnLoading) return '登录中...';
        return '登录';
      }
    },
    methods: {
      login() {
        if (!this.userName) {
          this.$message.error('请输入用户名');
          return;
        }
        if (!this.password) {
          this.$message.error('请输入密码');
          return;
        }

      }
    }
  }
</script>
<style>
  .login_form {
    padding-top: 10%;
    padding-left: 10%;
    padding-right: 10%;
  }
  .qxs-ic_user {
    background: url("../../assets/login/ic_user.png") no-repeat;
    background-size: 13px 15px;
    background-position: 3%;
  }
  .qxs-ic_password {
    background: url("../../assets/login/ic_password.png") no-repeat;
    background-size: 13px 15px;
    background-position: 3%;
    margin-bottom: 20px;
  }
  .login_logo {
    height: 100%;
  }
  .login_btn {
    width: 100%;
    font-size: 16px;
    background: -webkit-linear-gradient(left, #000099, #2154FA); /* Safari 5.1 - 6.0 */
    background: -o-linear-gradient(right, #000099, #2154FA); /* Opera 11.1 - 12.0 */
    background: -moz-linear-gradient(right, #000099, #2154FA); /* Firefox 3.6 - 15 */
    background: linear-gradient(to right, #000099 , #2154FA); /* 标准的语法 */
    filter: brightness(1.4);
  }
</style>

ic_password.png

使用Vue写一个登录页面

ic_user.png

使用Vue写一个登录页面

logo.png

使用Vue写一个登录页面

 

3.根据npm run dev 命令启动,启动完成之后会有个链接,访问链接就直接可以看到下面页面:

使用Vue写一个登录页面

 

问题交流群,不定期分享各种技术文档:

QQ群号:464512055

群二维码:

使用Vue写一个登录页面

这是一个神器的二维码,扫描之后你会少掉一块钱。

使用Vue写一个登录页面

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/143657.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • shiro框架—shiro配置介绍(一)

    shiro框架—shiro配置介绍(一)接上一篇文章shiro框架—关于用户登录和权限验证功能的实现步骤(二)shiro在springboot项目中的配置步骤1、引入依赖  首先shiro的应用,引入的依赖仅仅只有一个,即下边这个。&amp;amp;amp;amp;lt;dependency&amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;groupId&amp;amp;amp;amp;gt;org.apache.shiro&amp;amp

    2025年10月3日
    2
  • securecrt 乱码

    SecureCRT连接Linux时经常会看到乱码。发生乱码的原因主要是有三个地方1.Linux的etc的系统默认配置的编码2.用户环境变量里面设置的LANG变量3.SecureCRT会话变量里面的字符集的设置只要保持这三个地方的字条集编码保持一致就可以了。解决步骤如下:1.设置用户的环境变量查询当前用户的Local信息:[root@devdbserver…

    2022年4月7日
    59
  • Springboot整合一之Springboot整合RabbitMQ

    Springboot整合一之Springboot整合RabbitMQ目前,springboot已然成为了最热的java开发整合框架,主要是因其简单的配置,并且本身提供了很多与第三方框架的整合,甚至可以让我们在短短的几分钟里就可以搭建一个完整的项目架构。所以,博主打算近期写一些springboot整合案例,也不知道先写哪个,那就从最近的写起吧, 言归正传。。。…

    2022年5月15日
    40
  • pytest parametrize fixture_reno参数

    pytest parametrize fixture_reno参数前言当某个接口中的一个字段,里面规定的范围为1-5,你5个数字都要单独写一条测试用例,就太麻烦了,这个时候可以使用pytest.mark.parametrize装饰器可以实现测试用例参数化。官方示

    2022年7月30日
    5
  • ffmpeg下载安装教程_Anaconda安装ffmpeg

    ffmpeg下载安装教程_Anaconda安装ffmpeg最近在处理一些音频数据,ffmpeg是一款非常好用处理音视频的工具包。那什么是ffmpeg呢?FFmpeg是一套可以用来记录、转换数字音频、视频,并能将其转化为流的开源计算机程序,可以结合Java开发一些处理视频音频的功能。1.ffmpeg下载首先打开ffmpeg官网下载然后点击windows对应的图标,再点击下面的”WindowsEXEFile”随便选一个点进去选择一个版本下载。2.下载后解压,配置环境变量下载解压后就能在bin文件夹下能看到三个可执行程序:ffmpeg、ffpl

    2022年9月25日
    3
  • 海思Hi3798处理器参数,Hi3798芯片详细信息介绍

    海思Hi3798处理器参数,Hi3798芯片详细信息介绍Hi3798CV200集成4核64位高性能CortexA53处理器、内置NEON加速引擎,强大的CPU处理能力可以满足各种差异化的业务需求。在码流兼容性、在线视频播放的流畅性、图像质量以及整机性能方面保持业界最好的用户体验。支持4K2KP60@10bit超高清视频解码和显示,支持H.265/HEVC、H.264/AVC、AVS+、MVC、MPEG2、MPEG4、VC-1、VP6、VP…

    2022年6月30日
    117

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号