当前位置: 首页 > article >正文

二、0-1搭建springboot+vue3前后端分离-登录页面

项目仓库地址:zgw-admin: 从0-1搭建一个springboot+vue3的项目,这是源码

本次主要是为了:

a.写登录页面

b.element plus组件是否能正常使用

c.页面调用ts是否正常,无参和有参的函数

首页的图片:

页面效果

1、引入element plus组件,参考文档:
Element Plus 在Vue3项目中引入的三种方法_vue3引入elementplus组件-CSDN博客

npm install element-plus --save

2、安装完毕之后在main.ts里面加入加入代码:
 

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
和
​​​​​​​app.use(ElementPlus)

下面是完整的main.ts代码 

import './assets/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router from './router'

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'


const app = createApp(App)

app.use(createPinia())
app.use(router)
app.use(ElementPlus)

app.mount('#app')

3、新建登录页面,LoginView.vue

<script setup lang="ts">
import { reactive } from 'vue'
import { login, hello } from '@/api/home/LoginService'
    const formData = reactive({
        accountNo:'',
        password:'',
    });
    const imageurl = '../image/22.jpg';

    const handleLogin = () => {
        const data =  login()
        console.log('输出---->',data);
    }

</script>

<template>
  <div style="display: flex; justify-content: center; align-items: center;text-align: center;width: 100%; height: 100vh">
    <div style="width: 30%;height: auto;">
      <el-image style="width: 100%; height: 100%" :src="imageurl" />
    </div>
    <div style="width: 25%;height: auto;">
      <h3>欢迎登陆国际开趴</h3>
      <br>
      <el-form style="max-width: 600px;margin-left: 5px;" :model="formData">
        <el-form-item label="账号">
            <el-input v-model="formData.accountNo" />
        </el-form-item>
        <el-form-item label="密码">
            <el-input type="password" v-model="formData.password" />
        </el-form-item>
        <el-button type="primary" @click="hello(formData.accountNo)">Primary</el-button>
      </el-form>
    </div>
  </div>
  
  
</template>

<style scoped>
.body{
  background-color: rgb(21, 29, 22);
}
</style>

 4、新建登录api的ts文件



export const  resive  = async () => {
	return 'ggggggggg'
}

export const login = async () => {
	//const { data } = {id:'dd',};//await service.get(url)
    const data = {id:'sss',name:'dddd'}
	return data
}
export function hello(no?:string){
    console.log('hahahahahah========>',no);
    
  }


http://www.kler.cn/a/535953.html

相关文章:

  • oracle ORA-27054报错处理
  • MFC 的 CListCtrl 控件,使用SetItemState 方法来设置选中某个 item,如何达到效果和鼠标点击一致
  • PHP JSON操作指南
  • 用Python获取股票数据并实现未来收盘价的预测
  • E4982A,keysight是德科技台式LCR表
  • 【Prometheus】如何通过golang生成prometheus格式数据
  • 【Redis实战】投票功能
  • 深度剖析思科安全产品的特征以及技术特点
  • 【DeepSeek】DeepSeek小模型蒸馏与本地部署深度解析DeepSeek小模型蒸馏与本地部署深度解析
  • 【Elasticsearch】multi terms aggregation
  • 蓝桥杯字串简写(二分)
  • 火语言RPA--JSON提取
  • Go语言中的高阶函数
  • 【MySQL】centos 7 忘记数据库密码
  • Maven 构建生命周期与阶段详解
  • Redis存储⑤Redis五大数据类型之 List 和 Set。
  • Java面试场景题分享
  • stm32生成hex文件详解
  • 如何在 Kivy 中从按钮更新选项卡内容
  • 【重生之学习C语言----水仙花篇】
  • PostgreSQL:数据库迁移与版本控制
  • 【Unity3D小功能】Unity3D中实现超炫按钮悬停效果
  • Golang 并发机制-6:掌握优雅的错误处理艺术
  • SQL中Limit的用法详解
  • DeePseek结合PS!批量处理图片的方法教程
  • 【react】react面试题