1 06.结合@apply实现样式抽离
前面已经完成了 login 页面的开发,但是代码看起来有点臃肿,这里我们使用 @apply 实现样式抽离
<template>
<el-row class="login-container">
<!-- 登录页左边 -->
<el-col :lg="16" :md="12" class="left">
<div>
<div>欢迎光临</div>
<div>这是描述信息</div>
</div>
</el-col>
<!-- 登录页右边 -->
<el-col :lg="8" :md="12" class="right">
<h2 class="title">欢迎回来</h2>
<div>
<span class="line"></span>
<span>账号密码登录</span>
<span class="line"></span>
</div>
<el-form :model="form" class="w-[250px]">
<el-form-item>
<el-input v-model="form.username" placeholder="请输入用户名">
<template #prefix>
<el-icon><User /></el-icon>
</template>
</el-input>
</el-form-item>
<el-form-item>
<el-input type="password" v-model="form.password" placeholder="请输入用户密码" show-password>
<template #prefix>
<el-icon><Lock /></el-icon>
</template>
</el-input>
</el-form-item>
<el-form-item>
<el-button round color="#626aef" class="w-[250px] round" type="primary" @click="onSubmit">登录</el-button>
</el-form-item>
</el-form>
</el-col>
</el-row>
</template>
<script setup>
import { reactive } from 'vue'
// do not use same name with ref
const form = reactive({
username: '',
password: '',
})
const onSubmit = () => {
console.log('submit!')
}
</script>
<style scoped>
.login-container {
@apply min-h-screen;
}
.login-container .left, .login-container .right {
@apply flex justify-center items-center;
}
.login-container .left {
@apply bg-indigo-500;
}
.login-container .right {
@apply bg-light-500 flex-col ;
}
.left>div>div:first-child {
@apply text-3xl font-bold text-light-50 mb-8;
}
.left>div>div:last-child {
@apply text-gray-50 text-sm;
}
.right .title {
@apply font-bold text-gray-800 text-3xl;
}
.right>div {
@apply flex items-center justify-center my-5 text-gray-300 space-x-2;
}
.right .line {
@apply h-1 w-16 bg-gray-200;
}
</style>
Last updated