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

相关文章

Vue3 的 shallowRef 和 shallowReactive:优化性能

大家对 Vue3 的 ref 和 reactive 都很熟悉,那么对 shallowRef 和 shallowReactive 是否了解呢? 在编程和数据结构中,“shallow”(浅层)通常指对数据结构的最外层进行操作,而不递归地处理其内部或嵌套的数据。这种处理方式关注的是数据结构的第一层属性或元素,而忽略更深层次的嵌套内容。 1. 浅层与深层的对比 1.1 浅层(Shallow) 定义

JVM 的类初始化机制

前言 当你在 Java 程序中new对象时,有没有考虑过 JVM 是如何把静态的字节码(byte code)转化为运行时对象的呢,这个问题看似简单,但清楚的同学相信也不会太多,这篇文章首先介绍 JVM 类初始化的机制,然后给出几个易出错的实例来分析,帮助大家更好理解这个知识点。 JVM 将字节码转化为运行时对象分为三个阶段,分别是:loading 、Linking、initialization

Spring Security 基于表达式的权限控制

前言 spring security 3.0已经可以使用spring el表达式来控制授权,允许在表达式中使用复杂的布尔逻辑来控制访问的权限。 常见的表达式 Spring Security可用表达式对象的基类是SecurityExpressionRoot。 表达式描述hasRole([role])用户拥有制定的角色时返回true (Spring security默认会带有ROLE_前缀),去

浅析Spring Security认证过程

类图 为了方便理解Spring Security认证流程,特意画了如下的类图,包含相关的核心认证类 概述 核心验证器 AuthenticationManager 该对象提供了认证方法的入口,接收一个Authentiaton对象作为参数; public interface AuthenticationManager {Authentication authenticate(Authenti

Spring Security--Architecture Overview

1 核心组件 这一节主要介绍一些在Spring Security中常见且核心的Java类,它们之间的依赖,构建起了整个框架。想要理解整个架构,最起码得对这些类眼熟。 1.1 SecurityContextHolder SecurityContextHolder用于存储安全上下文(security context)的信息。当前操作的用户是谁,该用户是否已经被认证,他拥有哪些角色权限…这些都被保

Spring Security基于数据库验证流程详解

Spring Security 校验流程图 相关解释说明(认真看哦) AbstractAuthenticationProcessingFilter 抽象类 /*** 调用 #requiresAuthentication(HttpServletRequest, HttpServletResponse) 决定是否需要进行验证操作。* 如果需要验证,则会调用 #attemptAuthentica

Spring Security 从入门到进阶系列教程

Spring Security 入门系列 《保护 Web 应用的安全》 《Spring-Security-入门(一):登录与退出》 《Spring-Security-入门(二):基于数据库验证》 《Spring-Security-入门(三):密码加密》 《Spring-Security-入门(四):自定义-Filter》 《Spring-Security-入门(五):在 Sprin

Java架构师知识体认识

源码分析 常用设计模式 Proxy代理模式Factory工厂模式Singleton单例模式Delegate委派模式Strategy策略模式Prototype原型模式Template模板模式 Spring5 beans 接口实例化代理Bean操作 Context Ioc容器设计原理及高级特性Aop设计原理Factorybean与Beanfactory Transaction 声明式事物

不懂推荐算法也能设计推荐系统

本文以商业化应用推荐为例,告诉我们不懂推荐算法的产品,也能从产品侧出发, 设计出一款不错的推荐系统。 相信很多新手产品,看到算法二字,多是懵圈的。 什么排序算法、最短路径等都是相对传统的算法(注:传统是指科班出身的产品都会接触过)。但对于推荐算法,多数产品对着网上搜到的资源,都会无从下手。特别当某些推荐算法 和 “AI”扯上关系后,更是加大了理解的难度。 但,不了解推荐算法,就无法做推荐系

这15个Vue指令,让你的项目开发爽到爆

1. V-Hotkey 仓库地址: github.com/Dafrok/v-ho… Demo: 戳这里 https://dafrok.github.io/v-hotkey 安装: npm install --save v-hotkey 这个指令可以给组件绑定一个或多个快捷键。你想要通过按下 Escape 键后隐藏某个组件,按住 Control 和回车键再显示它吗?小菜一碟: <template