1 05.登录页图标引入响应式开发
npm install @element-plus/icons-vue
...略
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component)
}
...略
<template>
<el-row class="min-h-screen">
<el-col :lg="16" :md="12" class="bg-indigo-500 flex justify-center items-center">
<div>
<div class="text-3xl font-bold text-light-50 mb-8">欢迎光临</div>
<div class="text-gray-50 text-sm">这是描述信息</div>
</div>
</el-col>
<el-col :lg="8" :md="12" class="bg-light-500 flex justify-center items-center flex-col">
<h2 class="font-bold text-gray-800 text-3xl">欢迎回来</h2>
<div class="flex items-center justify-center my-5 text-gray-300 space-x-2">
<span class="h-1 w-16 bg-gray-200"></span>
<span>账号密码登录</span>
<span class="h-1 w-16 bg-gray-200"></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>
// src/router/index.js
import Login from '~/pages/login.vue'
const routes = [
...略
{ path: "/login", component: Login, name: "login"}, // +
]
Last updated