代码
<template>
<div class="login">
<a-card title="登 录" :bordered="true" class="containers">
<a-form-model layout="vertical" :model="loginForm" @submit="handleSubmit" @submit.native.prevent>
<a-form-model-item>
<a-input v-model="loginForm.username" placeholder="用户名" style="width:300px">
<a-icon slot="prefix" type="user" style="color:rgba(0,0,0,.25)"/>
</a-input>
</a-form-model-item>
<a-form-model-item>
<a-input v-model="loginForm.password" type="password" placeholder="密 码" style="width:300px">
<a-icon slot="prefix" type="lock" style="color:rgba(0,0,0,.25)" />
</a-input>
</a-form-model-item>
<a-form-model-item>
<a-button type="primary" html-type="submit" :disabled="loginForm.username === '' || loginForm.password === ''" style="width:300px">
登 录
</a-button>
</a-form-model-item>
</a-form-model>
</a-card>
</div>
</template>
<script>
export default {
data() {
return {
loginForm:{
username: '',
password: '',
},
};
},
methods: {
handleSubmit() {
console.log(this.loginForm);
},
},
};
</script>
<style scoped>
.login{
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>