<template>
  <div class="login">
    <el-form ref="form" :model="formData" label-width="80px">
      <el-form-item label="用户名" prop="username">
        <el-input v-model.lazy="formData.username"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="password">
        <el-input type="password" v-model.lazy="formData.password"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="login">登录</el-button>
        <el-button @click="reset">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup>
  import { reactive } from 'vue'
  import { ElForm, ElFormItem, ElInput, ElButton } from 'element-plus'

  const formData = reactive({
    username: '',
    password: ''
  })

  const login = () => {
    // 登录操作
  }

  const reset = () => {
    // 重置表单
    const form = refs.form
    form.resetFields()
    formData.username = ''
    formData.password = ''
  }
</script>

<style scoped>
 .login { width: 400px; margin: 50px auto; text-align: center; }

.login el-form { margin-top: 20px; }

.login el-form-item { margin-bottom: 15px; }

.login el-button { margin-right: 10px; } 
</style>
