1.给el-from绑定一个form
<el-form :model="loginForm" label-width="0px" class="login_form" >
2.在data中注册对象
loginForm:{
username:"ssdd",
password:"123"
}
3.绑定对象
<el-form-item >
<el-input v-model="loginForm.username" prefix-icon="iconfont icon-denglu" class="icon"></el-input>
</el-form-item>
<!-- 密码 -->
<el-form-item >
<el-input v-model="loginForm.password" prefix-icon="iconfont icon-mima" class="icon" type="password"></el-input>
</el-form-item>
这里密码由于是隐藏的,可以将它的type值换成password
代码显示:
<template>
<div class='login_container'>
<div class='longin_box'>
<!-- 头像区域 -->
<div class='avatar_box'>
<img src='../../assets/images/header.png' alt="">
</div>
<!-- 登录表单区域 -->
<el-form :model="loginForm" label-width="0px" class="login_form" >
<!-- 用户名 -->
<el-form-item >
<el-input v-model="loginForm.username" prefix-icon="iconfont icon-denglu" class="icon"></el-input>
</el-form-item>
<!-- 密码 -->
<el-form-item >
<el-input v-model="loginForm.password" prefix-icon="iconfont icon-mima" class="icon" type="password"></el-input>
</el-form-item>
<!-- 按钮区域 -->
<el-form-item class="btns">
<el-button type="primary">登录</el-button>
<el-button type="info">重置</el-button>
</el-form-item>
</el-form>
</div>
</div>
</template>
<script>
export default {
name: '',
data() {
return {
loginForm:{
username:"ssdd",
password:"123"
}
};