vue+springboot登录与注册功能的实现

这篇具有很好参考价值的文章主要介绍了vue+springboot登录与注册功能的实现。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

①首先写一个登录页面

<template>
<div style="background-color: #42b983;display: flex;align-items: center;justify-content: center;height: 100vh">
  <div style="background-color: white;display: flex;width: 50%;height: 50%;overflow: hidden;border-radius: 5px">
    <div style="flex:1">
      <img src="@/assets/login.png" style="width: 100%">
    </div>
    <div style="flex: 1;display: flex;justify-content: center;align-items: center">
      <el-form style="width: 80%" :model="user">
        <div style="font-weight: bold;font-size: 20px;margin-bottom: 20px">
          欢迎登录后台管理系统
        </div>
        <el-form-item>
          <el-input placeholder="请输入用户名" prefix-icon="el-icon-user" v-model="user.username"></el-input>
        </el-form-item>
        <el-form-item>
          <el-input placeholder="请输入密码" prefix-icon="el-icon-lock" v-model="user.password" show-password></el-input>
        </el-form-item>
        <el-form-item>
          <el-input placeholder="请输入验证码" prefix-icon="el-icon-circle-check" v-model="user.validcode"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" style="width: 100%">登录</el-button>
        </el-form-item>
        <div style="display: flex">
          <div style="flex: 1">还没账号?去<span style="color: #42b983;cursor: pointer">注册</span></div>
          <div style="text-align: right;flex: 1;color: #42b983;cursor:pointer;">忘记密码</div>
        </div>
      </el-form>
    </div>
  </div>
</div>
</template>
<script>
export default {
  data(){
    return{
      user:{
        username:'',
        password:'',
        validcode:''
      }
    }
  }
}
</script>
<style scoped>

</style>

 大致效果:

vue+springboot登录与注册功能的实现,vue.js,spring boot,javascript

 ②引入验证码组件

在component目录下新建一个ValidCode.vue:

vue+springboot登录与注册功能的实现,vue.js,spring boot,javascript

<template>
  <div class="ValidCode disabled-select" style="width: 100%; height: 100%" @click="refreshCode">
    <span v-for="(item, index) in codeList" :key="index" :style="getStyle(item)">{{item.code}}</span>
  </div>
</template>

<script>
export default {
  name: 'validCode',
  data () {
    return {
      length: 4,
      codeList: []
    }
  },
  mounted () {
    this.createdCode()
  },
  methods: {
    refreshCode () {
      this.createdCode()
    },
    createdCode () {
      let len = this.length,
          codeList = [],
          chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz0123456789',
          charsLen = chars.length
      // 生成
      for (let i = 0; i < len; i++) {
        let rgb = [Math.round(Math.random() * 220), Math.round(Math.random() * 240), Math.round(Math.random() * 200)]
        codeList.push({
          code: chars.charAt(Math.floor(Math.random() * charsLen)),
          color: `rgb(${rgb})`,
          padding: `${[Math.floor(Math.random() * 10)]}px`,
          transform: `rotate(${Math.floor(Math.random() * 90) - Math.floor(Math.random() * 90)}deg)`
        })
      }
      // 指向
      this.codeList = codeList
      // 将当前数据派发出去
      this.$emit('update:value', codeList.map(item => item.code).join(''))
    },
    getStyle (data) {
      return `color: ${data.color}; font-size: ${data.fontSize}; padding: ${data.padding}; transform: ${data.transform}`
    }
  }
}
</script>

<style>
.ValidCode{
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}
.ValidCode span {
  display: inline-block;
  font-size: 18px;
}
</style>

在登录页引入:

<template>
<div style="background-color: #42b983;display: flex;align-items: center;justify-content: center;height: 100vh">
  <div style="background-color: white;display: flex;width: 50%;height: 50%;overflow: hidden;border-radius: 5px">
    <div style="flex:1">
      <img src="@/assets/login.png" style="width: 100%">
    </div>
    <div style="flex: 1;display: flex;justify-content: center;align-items: center">
      <el-form style="width: 80%" :model="user">
        <div style="font-weight: bold;font-size: 20px;margin-bottom: 20px">
          欢迎登录后台管理系统
        </div>
        <el-form-item>
          <el-input placeholder="请输入用户名" prefix-icon="el-icon-user" v-model="user.username"></el-input>
        </el-form-item>
        <el-form-item>
          <el-input placeholder="请输入密码" prefix-icon="el-icon-lock" v-model="user.password" show-password></el-input>
        </el-form-item>
        <el-form-item>
          <div style="display: flex">
            <el-input placeholder="请输入验证码" prefix-icon="el-icon-circle-check" v-model="user.validCode" style="flex: 1"></el-input>
            <div style="flex: 1;height: 32px">
              <valid-code @update:value="getCode"></valid-code>
            </div>
          </div>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" style="width: 100%">登录</el-button>
        </el-form-item>
        <div style="display: flex">
          <div style="flex: 1">还没账号?去<span style="color: #42b983;cursor: pointer">注册</span></div>
          <div style="text-align: right;flex: 1;color: #42b983;cursor:pointer;">忘记密码</div>
        </div>
      </el-form>
    </div>
  </div>
</div>
</template>
<script>
import ValidCode from "@/components/ValidCode.vue";

export default {
  name:'login-demo',
  components:{
    ValidCode
  },
  data(){
    return{
      code:'',
      user:{
        username:'',
        password:'',
        validCode:''
      }
    }
  },
  methods:{
    getCode(code){
      this.code=code
    }
  }
}
</script>
<style scoped>

</style>

 效果图(可以看到多了验证码):

vue+springboot登录与注册功能的实现,vue.js,spring boot,javascript

③springboot搭建后端接口

首先准备数据库:

vue+springboot登录与注册功能的实现,vue.js,spring boot,javascript

CREATE TABLE `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '用户名',
  `password` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '密码',
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '姓名',
  `phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '电话',
  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '邮箱',
  `address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址',
  `avatar` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '头像',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户表';

 用IDEA创建springboot工程:

创建springboot教程

vue+springboot登录与注册功能的实现,vue.js,spring boot,javascript

连接数据库:

application.yml:

server:
  port: 9090
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/honey2024?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
    username: root
    password: 123456

目录结构:

按照该目录创建文件夹

vue+springboot登录与注册功能的实现,vue.js,spring boot,javascript

 CorsConfig:解决跨域问题

package com.example.springboot.common;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

@Configuration
public class CorsConfig {

    // 当前跨域请求最大有效时长。这里默认1天
    private static final long MAX_AGE = 24 * 60 * 60;

    @Bean
    public CorsFilter corsFilter() {
        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
        CorsConfiguration corsConfiguration = new CorsConfiguration();
        corsConfiguration.addAllowedOrigin("*"); // 1 设置访问源地址
        corsConfiguration.addAllowedHeader("*"); // 2 设置访问源请求头
        corsConfiguration.addAllowedMethod("*"); // 3 设置访问源请求方法
        corsConfiguration.setMaxAge(MAX_AGE);
        source.registerCorsConfiguration("/**", corsConfiguration); // 4 对接口配置跨域设置
        return new CorsFilter(source);
    }
}

Result:返回数据

package com.example.springboot.common;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 接口统一返回包装类
 * 作者:程序员青戈
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Result {

    public static final String CODE_SUCCESS = "200";
    public static final String CODE_AUTH_ERROR = "401";
    public static final String CODE_SYS_ERROR = "500";

    private String code;
    private String msg;
    private Object data;


    public static Result success() {
        return new Result(CODE_SUCCESS, "请求成功", null);
    }

    public static Result success(Object data) {
        return new Result(CODE_SUCCESS, "请求成功", data);
    }

    public static Result error(String msg) {
        return new Result(CODE_SYS_ERROR, msg, null);
    }

    public static Result error(String code, String msg) {
        return new Result(code, msg, null);
    }

    public static Result error() {
        return new Result(CODE_SYS_ERROR, "系统错误", null);
    }

}

WebController(controller文件夹下只用写这个):控制登录和注册接口

package com.example.springboot.controller;

import cn.hutool.core.util.StrUtil;
import com.example.springboot.common.Result;
import com.example.springboot.entity.User;
import com.example.springboot.exception.ServiceException;
import com.example.springboot.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
public class WebController {
    @Resource
    UserService userService;

    @GetMapping("/")
    public Result hello(){
        return Result.success("success");
    }

    @PostMapping("/login")
    public Result login(@RequestBody User user){
        if(StrUtil.isBlank(user.getUsername())||StrUtil.isBlank(user.getPassword())){
            return Result.error("数据输入错误");
        }
        user=userService.login(user);
        return Result.success(user);
    }

    @PostMapping("/register")
    public Result register(@RequestBody User user){
        if(StrUtil.isBlank(user.getUsername())||StrUtil.isBlank(user.getPassword())){
            throw new ServiceException("输入不合法");
        }
        if(user.getUsername().length()>10||user.getPassword().length()>20){
            throw new ServiceException("长度过长");
        }
        user=userService.register(user);
        return Result.success(user);
    }
}

User:用户实体类,用来承接数据

package com.example.springboot.entity;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
public class User {
    private Integer id;
    private String username;
    private String password;
    private String name;
    private String phone;
    private String email;
    private String address;
    private String avatar;
}

GlobalException:引入自定义并使用

package com.example.springboot.exception;

import com.example.springboot.common.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExeception {

    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public Result serviceException(ServiceException e){
        return Result.error("500",e.getMessage());
    }
}

ServiceException: 自定义异常

package com.example.springboot.exception;

public class ServiceException extends RuntimeException{
    public ServiceException(String msg){
        super(msg);
    }
}

UserMapper:定义接口,对数据库进行增删改查

package com.example.springboot.mapper;

import com.example.springboot.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    @Insert("insert into `user` (username, password, name, phone, email, address, avatar) " +
            "values (#{username}, #{password}, #{name}, #{phone}, #{email}, #{address}, #{avatar})")
    void insert(User user);

    @Update("update `user` set username = #{username} , password = #{password} , name = #{name} , phone=#{phone} , email = #{email} , avatar=#{avatar} where id = #{id}")
    void updateUser(User user);

    @Delete("delete from `user` where id=#{id}")
    void deleteUser(Integer id);

    @Select("select * from `user` order by id desc")
    List<User> selectall();

    @Select("select * from `user` where id =#{id} order by id desc")
    User selectbyid(Integer id);

    @Select("select * from `user` where name = #{name} order by id desc")
    List<User> selectbyname(String name);
    @Select("select * from `user` where username = #{username} and name = #{name} order by id desc")
    List<User> selectbymore(@Param("username") String username,@Param("name") String name);

    @Select("select * from `user` where username like  concat('%',#{username},'%') or name like concat('%',#{name},'%') order by id desc")
    List<User> selectbymo(@Param("username") String username,@Param("name") String name);

    @Select("select * from `user` where username = #{username} order by id desc")
    User selectbyUsername(String username);
}

Userservice:给接口编写实体方法

package com.example.springboot.service;

import com.example.springboot.entity.User;
import com.example.springboot.exception.ServiceException;
import com.example.springboot.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@Service
public class UserService {
    @Autowired
    UserMapper userMapper;
    public void insertUser(User user){
        userMapper.insert(user);
    }

    public void updateUser(User user) {
        userMapper.updateUser(user);
    }

    public void deleteUser(Integer id) {
        userMapper.deleteUser(id);
    }

    public void batchdeleteUser(List<Integer> ids) {
        for(Integer id : ids){
            userMapper.deleteUser(id);
        }
    }


    public List<User> selectall() {
        return userMapper.selectall();
    }

    public User selectbyid(Integer id) {
        return userMapper.selectbyid(id);
    }

    public List<User> selectbyname(String name) {
        return userMapper.selectbyname(name);
    }

    public List<User> selectbymore(String username, String name) {
        return userMapper.selectbymore(username,name);
    }

    public List<User> selectbymo(String username, String name) {
        return userMapper.selectbymo(username,name);
    }

    public User login(User user) {
        User dbuser=userMapper.selectbyUsername(user.getUsername());
        if(dbuser == null){
            throw new ServiceException("账号不存在");
        }
        if(!user.getPassword().equals(dbuser.getPassword())){
            throw new ServiceException("账号或者密码错误");
        }
        return dbuser;
    }

    public User register(User user) {
        User dbuser=userMapper.selectbyUsername(user.getUsername());
        if(dbuser != null){
            throw new ServiceException("用户名已存在");
        }
        userMapper.insert(user);
        return user;
    }
}

 引入hutool:在pom.xml引进依赖

<dependency>
  <groupId>cn.hutool</groupId>
  <artifactId>hutool-all</artifactId>
  <version>5.8.18</version>
</dependency>

 ④封装vue的网络请求

在vue终端安装依赖:

npm i axios

在vue中新建utils文件夹,该文件夹下新建request.js文件:

import axios from 'axios'

// 创建可一个新的axios对象
const request = axios.create({
    baseURL: 'http://localhost:9090',   // 后端的接口地址  ip:port
    timeout: 30000
})

// request 拦截器
// 可以自请求发送前对请求做一些处理
// 比如统一加token,对请求参数统一加密
request.interceptors.request.use(config => {
    config.headers['Content-Type'] = 'application/json;charset=utf-8';
    // let user = localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : null
    // config.headers['token'] = 'token'  // 设置请求头

    return config
}, error => {
    console.error('request error: ' + error) // for debug
    return Promise.reject(error)
});

// response 拦截器
// 可以在接口响应后统一处理结果
request.interceptors.response.use(
    response => {
        let res = response.data;

        // 兼容服务端返回的字符串数据
        if (typeof res === 'string') {
            res = res ? JSON.parse(res) : res
        }
        return res;
    },
    error => {
        console.error('response error: ' + error) // for debug
        return Promise.reject(error)
    }
)


export default request

main.js引入:

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import request from "@/utils/request";
Vue.config.productionTip = false
Vue.use(ElementUI,{size:'small'});
Vue.prototype.$request=request //引入request
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')

登录页补充登录函数:

<template>
<div style="background-color: #42b983;display: flex;align-items: center;justify-content: center;height: 100vh">
  <div style="background-color: white;display: flex;width: 50%;height: 50%;overflow: hidden;border-radius: 5px">
    <div style="flex:1">
      <img src="@/assets/login.png" style="width: 100%">
    </div>
    <div style="flex: 1;display: flex;justify-content: center;align-items: center">
      <el-form style="width: 80%" :model="user">
        <div style="font-weight: bold;font-size: 20px;margin-bottom: 20px">
          欢迎登录后台管理系统
        </div>
        <el-form-item>
          <el-input placeholder="请输入用户名" prefix-icon="el-icon-user" v-model="user.username"></el-input>
        </el-form-item>
        <el-form-item>
          <el-input placeholder="请输入密码" prefix-icon="el-icon-lock" v-model="user.password" show-password></el-input>
        </el-form-item>
        <el-form-item>
          <div style="display: flex">
            <el-input placeholder="请输入验证码" prefix-icon="el-icon-circle-check" v-model="user.validCode" style="flex: 1"></el-input>
            <div style="flex: 1;height: 32px">
              <valid-code @update:value="getCode"></valid-code>
            </div>
          </div>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" style="width: 100%" @click="login">登录</el-button>
        </el-form-item>
        <div style="display: flex">
          <div style="flex: 1">还没账号?去<span style="color: #42b983;cursor: pointer">注册</span></div>
          <div style="text-align: right;flex: 1;color: #42b983;cursor:pointer;">忘记密码</div>
        </div>
      </el-form>
    </div>
  </div>
</div>
</template>
<script>
import ValidCode from "@/components/ValidCode.vue";

export default {
  name:'login-demo',
  components:{
    ValidCode
  },
  data(){
    return{
      code:'',
      user:{
        username:'',
        password:'',
        validCode:''
      }
    }
  },
  methods:{
    getCode(code){
      this.code=code
    },
    login(){
      this.$request.post('/login',this.user).then(res=>{
        console.log(res)
      })
    }
  }
}
</script>
<style scoped>

</style>

效果图:

vue+springboot登录与注册功能的实现,vue.js,spring boot,javascript

⑤表单验证

 填写完表单验证规则后就是最终代码:

<template>
<div style="background-color: #42b983;display: flex;align-items: center;justify-content: center;height: 100vh">
  <div style="background-color: white;display: flex;width: 50%;height: 50%;overflow: hidden;border-radius: 5px">
    <div style="flex:1">
      <img src="@/assets/login.png" style="width: 100%">
    </div>
    <div style="flex: 1;display: flex;justify-content: center;align-items: center">
      <el-form style="width: 80%" :model="user" :rules="rules" ref="loginRef">
        <div style="font-weight: bold;font-size: 20px;margin-bottom: 20px">
          欢迎登录后台管理系统
        </div>
        <el-form-item prop="username">
          <el-input placeholder="请输入用户名" prefix-icon="el-icon-user" v-model="user.username"></el-input>
        </el-form-item>
        <el-form-item prop="password">
          <el-input placeholder="请输入密码" prefix-icon="el-icon-lock" v-model="user.password" show-password></el-input>
        </el-form-item>
        <el-form-item prop="code">
          <div style="display: flex">
            <el-input placeholder="请输入验证码" prefix-icon="el-icon-circle-check" v-model="user.code" style="flex: 1"></el-input>
            <div style="flex: 1;height: 32px">
              <valid-code @update:value="getCode"></valid-code>
            </div>
          </div>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" style="width: 100%" @click="login">登录</el-button>
        </el-form-item>
        <div style="display: flex">
          <div style="flex: 1">还没账号?去<span style="color: #42b983;cursor: pointer">注册</span></div>
          <div style="text-align: right;flex: 1;color: #42b983;cursor:pointer;">忘记密码</div>
        </div>
      </el-form>
    </div>
  </div>
</div>
</template>
<script>
import ValidCode from "@/components/ValidCode.vue";

export default {
  name:'login-demo',
  components:{
    ValidCode
  },
  data(){
    const validateCode = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请输入验证码'));
      } else if(value.toLowerCase() !== this.code){
        callback(new Error('验证码错误'));
      } else {
        callback();
      }
    };
    return{
      code:'',
      user:{
        username:'',
        password:'',
        code:''
      },
      rules:{
        username:[{
          required:true,trigger:'blur',message:'请输入用户名'
        }],
        password:[{
          required:true,trigger:'blur',message:'请输入密码'
        }],
        code:[{
          validator:validateCode,trigger:'blur'
        }],
      }
    }
  },
  methods:{
    getCode(code){
      this.code=code.toLowerCase()
    },
    login(){
      this.$refs['loginRef'].validate((valid)=>{
        if(valid){
          this.$request.post("/login",this.user).then(res=>{
            if(res.code === '200'){
              this.$router.push('/')
              this.$message.success('登录成功')
              localStorage.setItem('honey-user',JSON.stringify(res.data))
            }else{
              this.$message.error(res.msg)
            }
            console.log(res);
          })
        }
      })
    }
  }
}
</script>
<style scoped>

</style>

注册页面与登录页面代码逻辑相似:

<template>
  <div style="display: flex;align-items: center;justify-content: center;background-color: #669fefff;height: 100vh;">
    <div style="display: flex;width: 50%;background-color: white;border-radius: 5px;overflow: hidden;">
      <div style="flex: 1;">
        <img src="@/assets/register.png" alt="" style="width: 100%;">
      </div>
      <div style="flex: 1;display: flex;align-items: center;justify-content: center;">
        <el-form :model="user" style="width: 80%;" :rules="rules" ref="registerRef">
          <div style="font-weight: bold; font-size: 20px;margin-bottom: 20px;text-align: center;">
            欢迎注册后台管理系统
          </div>
          <el-form-item prop="username">
            <el-input placeholder="请输入用户名" v-model="user.username" prefix-icon="el-icon-user"></el-input>
          </el-form-item>
          <el-form-item prop="password">
            <el-input placeholder="请输入密码" v-model="user.password" show-password prefix-icon="el-icon-lock"></el-input>
          </el-form-item>
          <el-form-item prop="confirmPass">
            <el-input placeholder="请确认密码" v-model="user.confirmPass"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" style="width: 100%;" @click="register">注册</el-button>
          </el-form-item>
          <div style="display: flex;">
            <div style="flex: 1;text-align: left">已没有账号?去<span style="color:aquamarine;cursor: pointer;" @click="$router.push('/login')">登录</span></div>
          </div>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name:'register',
  data() {
    const validatePass = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请输入确认密码'));
      } else if(value !== this.user.password){
        callback(new Error('两次密码不一致'));
      } else {
        callback();
      }
    };
    return {
      code:'',
      user: {
        code:'',
        username: '',
        password: '',
        confirmPass:''
      },
      rules:{
        username:[{
          required:'true',message:'请输入账号',trigger:'blur'
        }],
        password:[{
          required:'true',message:'请输入密码',trigger:'blur'
        }],
        confirmPass:[{
          validator:validatePass,trigger:'blur'
        }],
      },
    }
  },
  methods:{
    getCode(code){
      this.code=code.toLowerCase()
    },
    register(){
      this.$refs['registerRef'].validate((valid=>{
        if(valid){
          this.$request.post("/register",this.user).then(res=>{
            if(res.code === '200'){
              this.$router.push('/login')
              this.$message.success('注册成功')
            }else{
              this.$message.error(res.msg)
            }
            console.log(res);
          })
        }
      }))
    }
  }
}
</script>

<style scoped></style>

最终效果:

vue+springboot登录与注册功能的实现,vue.js,spring boot,javascript

vue+springboot登录与注册功能的实现,vue.js,spring boot,javascript文章来源地址https://www.toymoban.com/news/detail-827207.html

到了这里,关于vue+springboot登录与注册功能的实现的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • Spring Boot 3 + Vue 3实战:引入数据库实现用户登录功能

    Spring Boot 3 + Vue 3实战:引入数据库实现用户登录功能

    ​ 本次实战,我们深入实践了基于数据库的用户登录功能开发。首先构建了包含id、username和password字段的 user 表,并初始化了测试数据。接着,在后端Spring Boot项目中集成MySQL数据库驱动与Druid连接池,以及MyBatis持久层框架,通过配置 application.yaml 文件来指定数据库连接信息

    2024年02月01日
    浏览(17)
  • js实现登录注册功能

    话不多说,上代码。 登录功能 注册功能

    2024年02月11日
    浏览(9)
  • 【论坛java项目】第二章 Spring Boot实践,开发社区登录模块:发送邮件、开发注册功能、会话管理、生成验证码、开发登录、退出功能、

    【论坛java项目】第二章 Spring Boot实践,开发社区登录模块:发送邮件、开发注册功能、会话管理、生成验证码、开发登录、退出功能、

    😀如果对你有帮助的话😊 🌺为博主点个赞吧 👍 👍点赞是对博主最大的鼓励😋 💓爱心发射~💓 bofryuzursekbiab——密码 访问邮箱域名 邮箱端口 账号 密码 协议 详细配置 JavaMailSender 是 Spring Email 的核心组件,负责发送邮件 MimeMessage 用于封装邮件的相关信息 MimeMessageHelper 用

    2024年02月06日
    浏览(13)
  • spring boot3登录开发-3(2短信验证登录/注册逻辑实现)

    spring boot3登录开发-3(2短信验证登录/注册逻辑实现)

      ⛰️个人主页:     蒾酒 🔥系列专栏:《spring boot实战》 🌊山高路远,行路漫漫,终有归途 目录 写在前面 上文衔接 内容简介 功能分析 短信验证登录实现 1.创建交互对象 用户短信登录/注册DTO 创建用户登录VO 2.创建自定义业务异常 创建验证码错误异常 创建用户被封禁异

    2024年04月09日
    浏览(9)
  • Vue项目二 登录注册功能的实现

    Vue项目二 登录注册功能的实现

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 环境搭建完,根据管理系统用户需要注册,实现登录然后将用户信息保存在本地中的需求,本章主要实现系统登录注册功能。 首先分析注册页面所要实现的功能,其功能包括账号、昵称、密码和二次确

    2023年04月08日
    浏览(16)
  • springboot实现最基础的登录注册功能(步骤详细,逻辑清晰)

    springboot实现最基础的登录注册功能(步骤详细,逻辑清晰)

    学了springboot2知识,就要用起来,不敲代码的程序员不是好程序员。笔者参考了他人的文章实现的这个功能,在自己的搭建过程中也遇到了许多问题,并花了一定的时间解决,下面开始吧! 首先,实现登录注册,我们是不是要先定义一个表?表里面要有什么,看看自己的需求

    2023年04月08日
    浏览(7)
  • 使用Spring Boot Security 实现多认证 手机号登录 微信扫码登录 微信扫码注册

    使用Spring Boot Security 实现多认证 手机号登录 微信扫码登录 微信扫码注册

    Spring Boot 3.x Spring Security 5.7 Spring Redis MyBatis plus 前端 Vue 公司 最近有个新项目 使用单点登录 sso 百度了一圈 也没怎么找到微信扫码注册的功能于是自己写 需求就是 手机 + 密码登录 微信扫码登录 微信扫码注册 微信二维码 登录 和注册二合一 具体实现 稍后我会说 本教程将指导

    2024年04月10日
    浏览(13)
  • Android前端+Spring Boot后端 登录功能实现

    Android前端+Spring Boot后端 登录功能实现

    创建项目后,自己添加包,框架如下   userController里的一些内容,只供参考,代码不全,无法实现 数据库是直接在社区版IDEA里连接Mysql,在控制台端创建的数据库和user表,用于数据交互。 Activity包里是Activity Java类,主要响应layout包里activity_login.xml等页面布局内的按钮响应 a

    2024年02月12日
    浏览(14)
  • 微服务系列文章之 Springboot+Vue实现登录注册

    微服务系列文章之 Springboot+Vue实现登录注册

    一、springBoot 创建springBoot项目   分为三个包,分别为controller,service, dao以及resource目录下的xml文件。 添加pom.xml 依赖 UserController.java   UserService.java   User.java (我安装了lombok插件)   UserMapper.java   UserMapper.xml   主干配置 application.yaml   数据库需要建相应得到表 1 2 3 4 CREA

    2024年02月13日
    浏览(10)
  • springboot+vue+elementsUI 实现分角色注册登录界面

    springboot+vue+elementsUI 实现分角色注册登录界面

    一、项目简介 一共分为三个角色:管理员、用户、设计师 登录功能:账号+密码+身份选择,登录成功后跳转到各身份对应的页面 注册功能:只允许用户和设计师注册,用户可以直接注册成功,设计师提交材料后注册需要管理员审核成功后方可注册成功。 注册页面要求必填:

    2024年02月07日
    浏览(83)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包