使用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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Ruby On Rails 4 hello world,Ruby On Rails上手

    Ruby On Rails 4 hello world,Ruby On Rails上手

    2021年11月29日
    37
  • C++——string字符串类具体用法

    C++——string字符串类具体用法引言:C++ 大大增强了对字符串的支持,除了可以使用C风格的字符串,还可以使用内置的 string 类。string 类处理起字符串来会方便很多,完全可以代替C语言中的字符数组或字符串指针。string 是 C++ 中常用的一个类,它非常重要,我们有必要在此单独讲解一下。定义使用 string 类需要包含头文件,下面的例子介绍了几种定义 string 变量(对象)的方法:#include…

    2022年8月18日
    21
  • 学习双拼必看(最全教程):双拼输入法的心得以及快速入门办法

    学习双拼必看(最全教程):双拼输入法的心得以及快速入门办法1.简单介绍一下双拼2.总共18种双拼方案3.15种双拼方案的具体映射4.顺便提一下双拼口诀的事情5.总结不同平台选择的方案双拼(也称双打)是一种建立在拼音输入法基础上的输入方法,可视为全拼的一种改进,它通过将汉语拼音中每个含多个字母的声母或韵母各自映射到某个按键上,使得每个音都可以用两个按键打出,极大地提高了拼音输入法的输入速度。这种声母或韵母到按键的对应表通常称之为双…

    2022年6月16日
    88
  • emule服务器地址列表地址

    emule服务器地址列表地址可能获得来源http://ed2k.2x4u.de/index.htmlServer.met地址.为ED2K使用..http://www.esel-paradies.de/server/server.methttp://www.edonkey2000.com/server.methttp://users.servicios.retecal.es/ljpadillam/Baltab/

    2022年6月15日
    648
  • sqrt mysql_详解MySQL中的SQRT函数的使用方法_MySQL

    sqrt mysql_详解MySQL中的SQRT函数的使用方法_MySQLMySQL的SQRT函数是用来计算出任何数量的平方根。可以使用SELECT语句找出方检定根的任意数如下:mysql>selectSQRT(16);+———-+|SQRT(16)|+———-+|4.000000|+———-+1rowinset(0.00sec)所看到的浮点值,因为内部MySQL将处理浮点数据类型的平方根。可以使用SQRT…

    2022年5月9日
    71
  • 如何和女生聊天不尬聊_女孩说和我聊天是尬聊

    如何和女生聊天不尬聊_女孩说和我聊天是尬聊大家好呀,我是辣条。写这篇文章的灵感来源于之前和朋友的聊天,真的无力吐槽了,想发适合的表情包怼回去却发现收藏的表情包就那几个,就想着是不是可以爬取一些表情包,再也不用尬聊了。先给大家看看我遇到的聊天最尬的场面:斗图吧图片采集抓取目标工具使用重点内容学习项目思路分析整理需求简易源码分享抓取目标网站:斗图吧工具使用开发环境:win10、python3.7开发工具:pycharm、Chrome工具包:requests、etree重点内容学习1.Q队列储存数据信息2.py多线程使用方法

    2022年9月17日
    0

发表回复

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

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