node.js肯定是个前提,之前已经安装了,接下来直接进入正题
1、先安装vue-cli,这里是全局安装,安装过了之后再建vue项目就可以不用再安装了
npm install vue-cli -g
2、创建项目
vue create bgmanage-vue
一路回车,但是注意有一项选项一定要选路由,不然后面要手写很麻烦。记录一下我的配置选项以免以后忘记
之后就一路enter接下来最后给以上的操作命名,这样以后就不用重复配置了
3、安装并引用element-ui
npm install element-ui --save
在src/main.js中写入以下
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)
4、创建登录页面
在src/view下创建页面,我们的登录页面叫做TheLogin.vue
<template>
<div class="login">
<div class="middle-wrapper">
<div class="title-wrapper">
<div class="title">什么鬼后台管理系统</div>
</div>
<div class="login-form">
<el-form>
<el-form-item prop="username">
<el-input placeholder="请输入账号">
<i slot="prefix" class="el-input__icon el-icon-adm-user" style="font-size: 18px;"></i>
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input placeholder="请输入密码">
<i slot="prefix" class="el-input__icon el-icon-adm-password" style="font-size: 18px;"></i>
<i slot="suffix" class="el-input__icon el-icon-view" style="cursor: pointer;"
></i>
</el-input>
</el-form-item>
<el-form-item style="margin-bottom: 0;">
<el-col :span="10" :offset="7">
<el-form-item>
<el-button
type="primary"
class="login-btn"
style="width: 100%;"
>
登陆系统
</el-button>
</el-form-item>
</el-col>
</el-form-item>
</el-form>
</div>
</div>
</div>
</template>
<script>
export default {
}
</script>
<style lang="scss" scoped>
.login {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
background: url('../assets/bgpic.jpg') no-repeat;
background-size: 100% 100%;
.middle-wrapper {
position: fixed;
width: 100%;
margin: 0 auto;
top: 50%;
transform: translateY(-60%);
.title-wrapper {
margin-top: 50px;
margin-bottom: 30px;
text-align: center;
font-size: 30px;
font-weight: bold;
color: #ffffff;
}
.login-form {
position: relative;
margin: 0 auto;
width: 520px;
padding: 30px 50px;
box-sizing: border-box;
border-radius: 5px;
background-color: rgba(255,255,255,.5);
.el-row {
margin-bottom: 20px;
&:last-child {
margin-bottom: 0;
}
.login-btn {
width: 100%;
}
}
.check-code-wrapper {
display: flex;
justify-content: space-between;
height: 40px;
.yanzhengma-wrapper {
flex: 0 1 auto;
}
.validate-code-wrapper {
flex: 0 0 160px;
}
}
}
}
}
</style>
5、创建登录页面的路由
在src/router.js里引入路由
import Login from './views/TheLogin.vue'
{
path: '/login',
component: Login
}
6、最终呈现