SpringBoot+Vue构建同学回忆录前台系统

本文主要是介绍SpringBoot+Vue构建同学回忆录前台系统,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

SpringBoot+Vue构建同学回忆录前台系统

前后端分离:

前端开发:

介绍一下vue的项目结构

在这里插入图片描述

dist:为编译后直接运行的目标文件

node_modules:为一些使用的模块和包

public:是一些项目的基本结构,里面包含着index.html,实际上也就是访问的是index.html

src:这就是我们的工程文件了

api:就是一些使用后端接口的前端接口

asset:这里面存放的是一些静态文件

components:这里用来编写一些通用组件,例如footer

router:用于编写路由

store:该项目里面的storeTemp就是,用来编写一些项目中用于保存一些中间数据的数据,例如token,账号信息。

utils:用来编写一些工具,可以对axios做二次封装

views:用来编写一些页面组件,和页面

之后的文件就不做赘述了,大家可以往后阅读就知道了

版本介绍:

Vue:3.0+

Element-ui:^2.15.6

这里不做过多的赘述:直接上图
在这里插入图片描述

开发过程:

1.通过webStrom直接选择vue项目搭建,自动生成vue-cli

2.配置vue.config.js

module.exports={//关闭代码校验lintOnSave:false,productionSourceMap: false,publicPath: './',outputDir: 'dist',assetsDir: 'assets',devServer: {port: 8090,host: 'localhost',https: false,open: false,proxy: {'/api': {target: `http://localhost:8001`,pathRewrite: { '^/api': '' },changeOrigin: true,}},disableHostCheck: true},}

上述有一个点并不是很明白,就是proxy的target,代理的目标地址,这里主要是用来指定后端的映射地址,也就是要改变index的proxyTable中的后端映射地址(默认是localhost:8080)我这里没有调试成功,所以直接在axios中配置了后端映射地址,这是错误的做法,后面会请教一些大佬更改过来。有知道的大佬也希望教教我这个小白。

好吧,这里配置并没有多少。现在介绍一下这个vue.config.js,这个对比vue2.0就好比是dev.config.js,有些人也会使用config包去做配置,这都是差不多的。不用纠结那么多。

可以看到上面有一个关闭代码校验的配置。

所以我们来配置一下哪些不用做代码校验的包,相信大家都对代码校验了如指掌。

创建一个.eslintignore文件

src/*
src/view/*

作完这些你以为我们的开发开始啦吗?其实并没有,我没还需要将src包做一下映射

创建一个jsconfig.json文件,将src包起一个别名@/

{"compilerOptions": {"baseUrl": "./","paths": {"@/*": ["src/*"]}},"exclude": ["node_modules","dist"]
}

好吧,配置了一堆,现在开始开发吧!

编写路由:

在src中创建一个router包,用来管理路由:

import Vue from "vue"
import VueRouter from "vue-router"
Vue.use(VueRouter)// import login from "@/views/login"export default new VueRouter({routes:[{path:"/",redirect:"/login",},{path:"/login",// redirect:"/hello",// component:login,component:()=>import("@/views/login"),// name:"登录",meta:{show:false},},{path:"/home",component:()=>import("@/views/Home"),meta:{show:true}}]
})

编写路由的时候要使用vue-router,先确保vue-router已经加入配置中。

编写之后还要继续在main.js中使用它哦

在这里插入图片描述

这里不展示import,也要加入我们刚刚写的包。

这里的meta信息是用于后面的v-show或者v-if

写了这么多,页面在哪里啊?

好吧,那我们就直接开整吧!

根据你编写的路由映射来views中编写页面

其实的话都是先编写页面,再来映射,不过问题不大

views开发:
<template><div class="hello"><div class="obj_body"><div class="login_body"><div class="login_left"></div><div class="login_right"><div class="login_form"><div class="filed"><input type="text" id="log_id" v-model = remUser.user_name @click="defaultChange"></div><div class="filed"><input type="password" id="log_paw" v-model = remUser.user_password ></div><div class="filed"><div class="two_fileds"><div><input type="checkbox" id="log_rem" name="log_rem_"><label >记住我</label></div></div><div class="two_fileds"><div><p><a href="#">注册</a></p></div></div></div><div class="filed"><button id="log_btn" @click="loginUser" @keydown="loginUser">登录</button></div></div></div></div></div><hr style="height:1px;border:none;border-top:1px solid #555555;" /><div class="obj_tail"><div class="tail_body"><div class="a_box"><ul><li id="th_list"><label id="_ha">关于我们</label></li><li><a href="#" id="com_a0_1">nihao</a></li><li><a href="#" id="com_a0_2">nihao</a></li><li><a href="#" id="com_a0_3">nihao</a></li></ul></div><div class="a_box"><ul><li id="th_list"><label id="_ha">关于我们</label></li><li><a href="#" id="com_a1_1">nihao</a></li><li><a href="#" id="com_a1_2">nihao</a></li><li><a href="#" id="com_a1_3">nihao</a></li><li><a href="#" id="com_a1_4">nihao</a></li><li><a href="#" id="com_a1_5">nihao</a></li><li><a href="#" id="com_a1_6">nihao</a></li></ul></div><div class="a_box"><ul><li id="th_list"><label id="_ha">关于我们</label></li><li><a href="#" id="com_a2_1">nihao</a></li><li><a href="#" id="com_a2_2">nihao</a></li><li><a href="#" id="com_a2_3">nihao</a></li></ul></div><div class="a_box"><ul><li id="th_list"><label id="_ha">关于我们</label></li><li><a href="#" id="com_a3_1">nihao</a></li><li><a href="#" id="com_a3_2">nihao</a></li><li><a href="#" id="com_a3_3">nihao</a></li></ul></div></div></div><div class="admin_user"><a id="a_img" href="#"><img src="images/R-C.jfif"  alt="图片加载失败"/></a><div class="tip_"><label>联系客服</label></div></div></div>
</template><script>
import {login}from "@/api/login"
export default {data() {return {remUser:{user_name:"账号",user_password:"",},}},methods:{defaultChange(){if(this.remUser.user_name === "账号"){this.remUser.user_name = ""}},loginUser(){this.$store.dispatch("Login",this.remUser).then(response=>{this.$message({type:"success",message:"登录成功"})this.$router.push({path:'/home'})}).catch(err=>{this.$message({type:"error",message:"登录失败"})console.log(err)})// login(this.remUser)//     .then(response=>{//       if(response.data.code === 20000){//         this.$message({//           type:"success",//           message:"登录成功"//         })//         this.$router.push({path:'/home'})//       }else{//         this.$message({//           type:"error",//           message:"登录失败"//         })//       }// }).catch(err=>{//   console.log(err)// })},enterLogin() {document.onkeydown = (e) => {e = window.event || e;if (this.$route.path === '/login' && (e.code === 'Enter' || e.code === 'enter')) {//调用登录事件方法this.loginUser();}}}},created() {this.enterLogin()}
}
</script><!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
* {margin: 0;padding: 0;
}.obj_body {height: 700px;position: relative;background-color: rgb(223, 221, 221);
}.obj_tail {height: 200px;/* background-color: yellow; */position: relative;background-color: rgb(223, 221, 221);
}.obj_body .login_body {border-radius: 20px;width: 800px;height: 500px;background-image: url("images/森林1.jpg");background-repeat: no-repeat;background-size: 800px 500px;position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);box-shadow: 0 0 10px 5px dimgray;
}.login_body .login_left {width: 50%;height: 100%;/* border-top-left-radius: 20px; *//* border-bottom-left-radius: 20px; */float: left;
}.login_body .login_right {position: relative;width: 50%;height: 100%;/* border-radius: 20px; */border-top-right-radius: 20px;border-bottom-right-radius: 20px;background-image: linear-gradient(to right, aqua, green);float: left;
}.login_right .login_form {position: absolute;bottom: 100px;right: 50px;text-align: center;
}.filed {overflow: hidden;margin-bottom: 10px;
}.filed input {width: 250px;height: 30px;border-radius: 15px;font-size: 18px;
}.filed input:first-child {color: dimgray;
}.filed #log_rem {width: 15px;height: 15px;box-shadow: 0 0 2px 2px dimgray;border-radius: 2px;
}.filed .two_fileds:first-child {text-align: left;
}.filed .two_fileds:last-child {text-align: right;
}.filed .two_fileds {float: left;width: 50%
}.two_fileds p a {text-decoration: none;color: black;
}.two_fileds p a:hover {color: rgb(134, 77, 77);
}.filed #log_btn {width: 150px;height: 30px;background-color: aqua;color: black;text-align: center;line-height: 30px;border-radius: 10px;
}.obj_tail .tail_body {position: absolute;width: 1000px;height: 160px;/* background-color: rgba(236, 233, 233, 0.904); */top: 50%;left: 50%;transform: translate(-50%, -50%);
}.tail_body .a_box {border-left: 1px solid rgb(83, 82, 82);width: 200px;height: 160px;margin-left: 10px;display: inline-block;
}.tail_body .a_box:first-child {margin-left: 75px;
}.tail_body .a_box:last-child {border-right: 1px solid rgb(83, 82, 82);
}.a_box li {float: left;width: 200px;height: 40px;display: block;
}.a_box #th_list {border-radius: 2px;/* background-color: rgb(223, 221, 221); */
}.a_box ul {height: 160px;list-style-type: none;margin: 0;padding: 0;overflow-y: auto;
}.a_box ul::-webkit-scrollbar {display: none;
}li>a {display: inline-block;width: 200px;height: 40px;text-decoration: none;text-align: center;line-height: 40px;font-size: 18px;color: rgb(68, 67, 67);
}#_ha {display: inline-block;width: 200px;height: 40px;text-align: center;line-height: 40px;font-size: 20px;color: rgb(68, 67, 67);
}li>a:hover {font-size: 21px;color: rgb(134, 77, 77);
}.admin_user a {margin: 0;padding: 0;display: inline-block;position: fixed;right: 30px;bottom: 30px;width: 60px;height: 60px;
}.admin_user a img {width: 60px;height: 60px;background-repeat: no-repeat;
}.admin_user .tip_ {display: none;/* visibility: hidden; */width: 100px;height: 40px;background-color: rgb(158, 154, 154);color: rgb(42, 20, 235);/* word-break: break-all; */text-align: center;border-radius: 6px;/* 定位 */position: fixed;right: 110px;bottom: 40px;
}.tip_ label {font-size: 18px;color: white;text-align: center;line-height: 40px;
}
</style>

你可以使用你熟悉的任何前端知识,我的目标不是前端工程师,所以对前端并不了解,但我也会努力去学习,css的话可以改用less开发。

这个文件是生存在Login包下的

里面引入了两张图片,在Login中添加一个image文件夹,然后将图片加入就好

还有一个首页哇!

首页的话又要编写头部组件,也是熟练工就好,那我们就交流到这里吧!

还希望大佬帮我解决一下上面的问题,十分感谢!

这篇关于SpringBoot+Vue构建同学回忆录前台系统的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/564863

相关文章

Spring boot整合dubbo+zookeeper的详细过程

《Springboot整合dubbo+zookeeper的详细过程》本文讲解SpringBoot整合Dubbo与Zookeeper实现API、Provider、Consumer模式,包含依赖配置、... 目录Spring boot整合dubbo+zookeeper1.创建父工程2.父工程引入依赖3.创建ap

SpringBoot结合Docker进行容器化处理指南

《SpringBoot结合Docker进行容器化处理指南》在当今快速发展的软件工程领域,SpringBoot和Docker已经成为现代Java开发者的必备工具,本文将深入讲解如何将一个SpringBo... 目录前言一、为什么选择 Spring Bootjavascript + docker1. 快速部署与

golang程序打包成脚本部署到Linux系统方式

《golang程序打包成脚本部署到Linux系统方式》Golang程序通过本地编译(设置GOOS为linux生成无后缀二进制文件),上传至Linux服务器后赋权执行,使用nohup命令实现后台运行,完... 目录本地编译golang程序上传Golang二进制文件到linux服务器总结本地编译Golang程序

Spring Boot spring-boot-maven-plugin 参数配置详解(最新推荐)

《SpringBootspring-boot-maven-plugin参数配置详解(最新推荐)》文章介绍了SpringBootMaven插件的5个核心目标(repackage、run、start... 目录一 spring-boot-maven-plugin 插件的5个Goals二 应用场景1 重新打包应用

SpringBoot+EasyExcel实现自定义复杂样式导入导出

《SpringBoot+EasyExcel实现自定义复杂样式导入导出》这篇文章主要为大家详细介绍了SpringBoot如何结果EasyExcel实现自定义复杂样式导入导出功能,文中的示例代码讲解详细,... 目录安装处理自定义导出复杂场景1、列不固定,动态列2、动态下拉3、自定义锁定行/列,添加密码4、合并

Spring Boot集成Druid实现数据源管理与监控的详细步骤

《SpringBoot集成Druid实现数据源管理与监控的详细步骤》本文介绍如何在SpringBoot项目中集成Druid数据库连接池,包括环境搭建、Maven依赖配置、SpringBoot配置文件... 目录1. 引言1.1 环境准备1.2 Druid介绍2. 配置Druid连接池3. 查看Druid监控

Java中读取YAML文件配置信息常见问题及解决方法

《Java中读取YAML文件配置信息常见问题及解决方法》:本文主要介绍Java中读取YAML文件配置信息常见问题及解决方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要... 目录1 使用Spring Boot的@ConfigurationProperties2. 使用@Valu

创建Java keystore文件的完整指南及详细步骤

《创建Javakeystore文件的完整指南及详细步骤》本文详解Java中keystore的创建与配置,涵盖私钥管理、自签名与CA证书生成、SSL/TLS应用,强调安全存储及验证机制,确保通信加密和... 目录1. 秘密键(私钥)的理解与管理私钥的定义与重要性私钥的管理策略私钥的生成与存储2. 证书的创建与

浅析Spring如何控制Bean的加载顺序

《浅析Spring如何控制Bean的加载顺序》在大多数情况下,我们不需要手动控制Bean的加载顺序,因为Spring的IoC容器足够智能,但在某些特殊场景下,这种隐式的依赖关系可能不存在,下面我们就来... 目录核心原则:依赖驱动加载手动控制 Bean 加载顺序的方法方法 1:使用@DependsOn(最直

SpringBoot中如何使用Assert进行断言校验

《SpringBoot中如何使用Assert进行断言校验》Java提供了内置的assert机制,而Spring框架也提供了更强大的Assert工具类来帮助开发者进行参数校验和状态检查,下... 目录前言一、Java 原生assert简介1.1 使用方式1.2 示例代码1.3 优缺点分析二、Spring Fr