Vant 实现简单的登录注册模块以及个人用户中心

2023-10-22 00:30

本文主要是介绍Vant 实现简单的登录注册模块以及个人用户中心,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

效果图:

  

代码:

  个人中心:

<template><div><div class="top"><div><img class="tar" src="@/assets/lz.jpg" alt=""><p style="float:left;color:#FFFFFF;margin-left:15px;margin-top:20px">可达鸭</p><div style="float:right;height:25px;background-color:#295F96;margin-top:25px;width: 80PX; border-radius: 15px 0px 0px 15px;color:#FFFFFF">&nbsp;<a href="#" style="color:#FFFFFF">今日待办</a></div></div><div>&nbsp;</div><div style="clear: both"><div style="margin-top:10px;color:#FFFFFF;float:left;margin-left:30px;"><div>动态</div><div>0</div></div><div style="margin-top:10px;color:#FFFFFF;float:left;margin-left:110px;"><div>关注</div><div>99</div></div><div style="margin-top:10px;color:#FFFFFF;float:left;margin-left:110px;"><div>粉丝</div><div>10</div></div></div></div><div style=""><div style="float:left;margin-left:30px;margin-top:10px"><div ><van-icon size="25" name="star-o" /></div><div style="margin-top:3px">收藏</div></div><div style="float:left;margin-left:110px;margin-top:10px"><div ><van-icon size="25" name="clock-o" /></div><div style="margin-top:3px">历史</div></div><div style="float:left;margin-left:110px;margin-top:10px"><div ><van-icon size="25" name="todo-list-o" /></div><div style="margin-top:3px">作品</div></div><div style="clear: both;;width:100%;height:10px"></div></div><div style="margin-top:10px; clear: both; border-top: 1px solid #e2e2ee;"><div>&nbsp;</div><div>内容区</div></div><div style="clear:both;"><van-tabbarv-model="active"active-color="#07c160"
><van-tabbar-item icon="home-o">标签</van-tabbar-item><van-tabbar-item icon="search">标签</van-tabbar-item><van-tabbar-item icon="fire-o">标签</van-tabbar-item><van-tabbar-item icon="setting-o">标签</van-tabbar-item>
</van-tabbar></div><div></div></div> 
</template>
<style scoped>.top{height: 150px;width: 100%;background-color: #1e87ff;margin-top:-58px}.tar{margin-top: 20px;height: 70px;width: 70px;border-radius: 50%;float: left;margin-left:10px;}
</style>
<script>import Tabbar from '@/components/tab/Tabbar.vue'export default{data(){return{userName:'',pwd:'',active: 0}},//axios //getApi()  ---> axios aixos.get('http://localhost:8080/api')//后端得到了请求 --数据处理 --数据传回 //本地的浏览器得到数据components:{Tabbar,},created(){var userLogin = localStorage.getItem("userLogin");userLogin =  JSON.parse(userLogin);console.log(userLogin.name);console.log(userLogin.pwd);this.userName = userLogin.name;this.pwd = userLogin.pwd;},methods:{exit(){localStorage.removeItem("userLogin"); //移除保存的数据this.$router.replace("/home");},onClickLeft() {Toast('返回');},onClickRight() {Toast('按钮');}}}
</script>
<style>.top{height: 100px;width: 100%;background-color: #1e87ff;margin-top:-58px}.tar{margin-top: 20px;height: 70px;width: 70px;border-radius: 50%;}
</style>

   登录:

<template><van-form @submit="onSubmit"><div ><div>&nbsp;</div><img class="tar" src="@/assets/lz.jpg" alt=""></div><van-fieldleft-icon="friends-o"v-model="username"style="margin-top:10px"name="用户名"label="用户 :"placeholder="请输入用户名":rules="[{ required: true, message: '请填写用户名' }]"label-width="50"class="input"/><van-fieldleft-icon="smile-comment-o"v-model="password"type="password"name="密码"label="密码 :"placeholder="请输入密码"label-width="50":rules="[{ required: true, message: '请填写密码' }]"class="input"/><div style="margin: 16px;"><van-button round block type="info"  native-type="submit">提交</van-button></div><div class="reg"><div @click="toRegister" style="font-size: small;">没有账号?立即注册</div></div></van-form></template>
<script>
import { Dialog } from 'vant';export default{data(){return{username:'',password:'',show:false,userList:[],}},methods:{onSubmit(){var list  = localStorage.getItem("userList");console.log(list);if(list == null ){Dialog.alert({title: '尊敬的用户您好:',message: '登录账户不存在,重新登录!',theme: 'round-button',}).then(() => {this.username = '';this.password = '';}); }else{this.userList = JSON.parse(list);for(var i = 0 ; i < this.userList.length ; i++){console.log(this.userList[i].name);console.log(this.userList[i].pwd);if(this.userList[i].name == this.username && this.userList[i].pwd == this.password){Dialog.alert({title: '尊敬的用户您好:',message: '登录成功!',theme: 'round-button',}).then(() => {this.$router.replace({path:'/home'});});localStorage.setItem("userLogin",JSON.stringify(this.userList[i]));return  ;}}Dialog.alert({title: '尊敬的用户您好:',message: '登录账户不存在,重新登录!',theme: 'round-button',}).then(() => {this.username = '';this.password = '';}); }},toRegister(){this.$router.replace('/user/register')}},components:{[Dialog.Component.name]: Dialog.Component,}}
</script>
<style scoped>/* .juli{margin-top: 50px;background-color: pink;} */.input{margin-top: 50px;border-bottom: 1px solid #e2e2ee;}.tar{margin-top: 20px;height: 70px;width: 70px;border-radius: 50%;}/* .back{} */
</style>

这篇关于Vant 实现简单的登录注册模块以及个人用户中心的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



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

相关文章

C++使用栈实现括号匹配的代码详解

《C++使用栈实现括号匹配的代码详解》在编程中,括号匹配是一个常见问题,尤其是在处理数学表达式、编译器解析等任务时,栈是一种非常适合处理此类问题的数据结构,能够精确地管理括号的匹配问题,本文将通过C+... 目录引言问题描述代码讲解代码解析栈的状态表示测试总结引言在编程中,括号匹配是一个常见问题,尤其是在

Java实现检查多个时间段是否有重合

《Java实现检查多个时间段是否有重合》这篇文章主要为大家详细介绍了如何使用Java实现检查多个时间段是否有重合,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录流程概述步骤详解China编程步骤1:定义时间段类步骤2:添加时间段步骤3:检查时间段是否有重合步骤4:输出结果示例代码结语作

使用C++实现链表元素的反转

《使用C++实现链表元素的反转》反转链表是链表操作中一个经典的问题,也是面试中常见的考题,本文将从思路到实现一步步地讲解如何实现链表的反转,帮助初学者理解这一操作,我们将使用C++代码演示具体实现,同... 目录问题定义思路分析代码实现带头节点的链表代码讲解其他实现方式时间和空间复杂度分析总结问题定义给定

Java覆盖第三方jar包中的某一个类的实现方法

《Java覆盖第三方jar包中的某一个类的实现方法》在我们日常的开发中,经常需要使用第三方的jar包,有时候我们会发现第三方的jar包中的某一个类有问题,或者我们需要定制化修改其中的逻辑,那么应该如何... 目录一、需求描述二、示例描述三、操作步骤四、验证结果五、实现原理一、需求描述需求描述如下:需要在

如何使用Java实现请求deepseek

《如何使用Java实现请求deepseek》这篇文章主要为大家详细介绍了如何使用Java实现请求deepseek功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1.deepseek的api创建2.Java实现请求deepseek2.1 pom文件2.2 json转化文件2.2

python使用fastapi实现多语言国际化的操作指南

《python使用fastapi实现多语言国际化的操作指南》本文介绍了使用Python和FastAPI实现多语言国际化的操作指南,包括多语言架构技术栈、翻译管理、前端本地化、语言切换机制以及常见陷阱和... 目录多语言国际化实现指南项目多语言架构技术栈目录结构翻译工作流1. 翻译数据存储2. 翻译生成脚本

C++初始化数组的几种常见方法(简单易懂)

《C++初始化数组的几种常见方法(简单易懂)》本文介绍了C++中数组的初始化方法,包括一维数组和二维数组的初始化,以及用new动态初始化数组,在C++11及以上版本中,还提供了使用std::array... 目录1、初始化一维数组1.1、使用列表初始化(推荐方式)1.2、初始化部分列表1.3、使用std::

如何通过Python实现一个消息队列

《如何通过Python实现一个消息队列》这篇文章主要为大家详细介绍了如何通过Python实现一个简单的消息队列,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录如何通过 python 实现消息队列如何把 http 请求放在队列中执行1. 使用 queue.Queue 和 reque

Python如何实现PDF隐私信息检测

《Python如何实现PDF隐私信息检测》随着越来越多的个人信息以电子形式存储和传输,确保这些信息的安全至关重要,本文将介绍如何使用Python检测PDF文件中的隐私信息,需要的可以参考下... 目录项目背景技术栈代码解析功能说明运行结php果在当今,数据隐私保护变得尤为重要。随着越来越多的个人信息以电子形

使用 sql-research-assistant进行 SQL 数据库研究的实战指南(代码实现演示)

《使用sql-research-assistant进行SQL数据库研究的实战指南(代码实现演示)》本文介绍了sql-research-assistant工具,该工具基于LangChain框架,集... 目录技术背景介绍核心原理解析代码实现演示安装和配置项目集成LangSmith 配置(可选)启动服务应用场景