# 1 05.登录页图标引入响应式开发

* #### 引入图标

```js
npm install @element-plus/icons-vue
```

* #### 全局引入图标 main.js

```js
...略
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

const app =  createApp(App)

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
  }

...略
```

* #### 登录组件： login.vue

```js
<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>
```

* ### 添加路由

```js
// src/router/index.js
import Login from '~/pages/login.vue'


const routes = [
    ...略
    { path: "/login", component: Login, name: "login"}, // +
]
```

* #### 效果

<div><img src="C:%5CUsers%5CAdministrator.DESKTOP-UK43ECI%5CAppData%5CRoaming%5Cmarktext%5Cimages%5C2023-02-16-18-35-42-image.png" alt=""> <figure><img src="https://2134947750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvILwbD2PrkBCkSitM3m4%2Fuploads%2FJe8z5CpCugsgLYEtPoBw%2F2023-02-16-18-35-42-image.png?alt=media&#x26;token=ce98813a-b4c1-46ac-a15f-6b56b2dcfff8" alt=""><figcaption></figcaption></figure></div>
