1.给el-from绑定一个form

  1. <el-form :model="loginForm" label-width="0px" class="login_form" >

2.在data中注册对象

  1. loginForm:{
  2. username:"ssdd",
  3. password:"123"
  4. }

3.绑定对象

  1. <el-form-item >
  2. <el-input v-model="loginForm.username" prefix-icon="iconfont icon-denglu" class="icon"></el-input>
  3. </el-form-item>
  4. <!-- 密码 -->
  5. <el-form-item >
  6. <el-input v-model="loginForm.password" prefix-icon="iconfont icon-mima" class="icon" type="password"></el-input>
  7. </el-form-item>

这里密码由于是隐藏的,可以将它的type值换成password
代码显示:

  1. <template>
  2. <div class='login_container'>
  3. <div class='longin_box'>
  4. <!-- 头像区域 -->
  5. <div class='avatar_box'>
  6. <img src='../../assets/images/header.png' alt="">
  7. </div>
  8. <!-- 登录表单区域 -->
  9. <el-form :model="loginForm" label-width="0px" class="login_form" >
  10. <!-- 用户名 -->
  11. <el-form-item >
  12. <el-input v-model="loginForm.username" prefix-icon="iconfont icon-denglu" class="icon"></el-input>
  13. </el-form-item>
  14. <!-- 密码 -->
  15. <el-form-item >
  16. <el-input v-model="loginForm.password" prefix-icon="iconfont icon-mima" class="icon" type="password"></el-input>
  17. </el-form-item>
  18. <!-- 按钮区域 -->
  19. <el-form-item class="btns">
  20. <el-button type="primary">登录</el-button>
  21. <el-button type="info">重置</el-button>
  22. </el-form-item>
  23. </el-form>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. export default {
  29. name: '',
  30. data() {
  31. return {
  32. loginForm:{
  33. username:"ssdd",
  34. password:"123"
  35. }
  36. };