<template>
<div class="login-container">
<el-form
:model="form"
status-icon
:rules="rules"
ref="ruleForm"
label-width="80px"
class="login-from"
>
<h2 class="login-title">CC&会员管理系统</h2>
<el-form-item label="账户">
<el-input type="text" :v-model="form.username"></el-input>
</el-form-item>
<el-form-item label="密码">
<el-input type="password" :v-model="form.password"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm('ruleForm')"
>提交</el-button
>
<el-button @click="resetForm('ruleForm')">重置</el-button>
</el-form-item>
</el-form>
</div>
</template>
<script>
export default {
data() {
return {
form: {
username: '',
password: ''
}
};
},
methods: {
submitForm() {
console.log('登录');
}
}
};
</script>
<style scoped>
/* 表单样式设置 */
.login-from {
width: 350px;
/* 居中 */
margin: 35vh auto;
background-color: rgb(255, 255, 255, 0.6);
padding: 30px;
border-radius: 20px;
}
/* 背景样式设置 */
.login-container {
position: absolute;
width: 100%;
height: 100%;
/* 背景图片的设置 */
background: url('../../assets/login.jpg') no-repeat;
background-size: 100% 100%;
}
/* 表单标题样式设置 */
.login-title {
color: #303133;
/* 居中 */
text-align: center;
}
</style>
静态资源放在 assets中
发现问题:背景图距离上方左方有一定的间距
原因:div默认有8像素
解决:app.vue中设置body样式 margin:0 auto;