vue.js - 登录用户的本地存储问题
问题描述
这里我使用本地存储。这里的用例是在我们的站点中,我们有两个用户,一个是企业用户,另一个是个人用户。所以这里是个人用个人用户登录,然后所有填充的值都保存在本地存储中,同一个用户用他的商业用户邮件登录,然后我正在使用之前填写的个人登录相同的值。所以我们不想显示在个人用户中不应该显示在商业用户中的值,所以如何实现这一点请帮助我本地存储两个不同的登录名,使用相同的邮件和相同的用户,但登录名是企业和个人
图式
schema_Real_Estate: {
fields: [{
type: "input",
inputType: "text",
placeholder: "Garages",
required: true,
model: "Garages",
styleClasses: ["half-width col-xs-12 col-sm-6", "job_title"]
}, {
type: "input",
inputType: "text",
placeholder: "Basement",
required: true,
model: "Basement",
styleClasses: ["half-width col-xs-12 col-sm-6", "Experience"]
}, {
type: "input",
inputType: "text",
placeholder: "Roof",
required: true,
model: "Roof",
styleClasses: ["half-width col-xs-12 col-sm-6", "job_title"]
}, {
type: "input",
inputType: "text",
placeholder: "Exterior",
required: true,
model: "Exterior",
styleClasses: ["half-width col-xs-12 col-sm-6", "Experience"]
}, {
type: "input",
inputType: "text",
placeholder: "Cooling",
required: true,
model: "Cooling",
styleClasses: ["half-width col-xs-12 col-sm-6", "job_title"]
}, {
type: "input",
inputType: "text",
placeholder: "Heating",
required: true,
model: "Heating",
styleClasses: ["half-width col-xs-12 col-sm-6", "Experience"]
}, {
type: "input",
inputType: "text",
placeholder: "Elementary school",
required: true,
model: "Elementary_school",
styleClasses: ["half-width col-xs-12 col-sm-4", "job_title"]
}, {
type: "input",
inputType: "text",
placeholder: "Middle school",
required: true,
model: "Middle_school",
styleClasses: ["half-width col-xs-12 col-sm-4", "Experience"]
}, {
type: "input",
inputType: "text",
placeholder: "High school",
required: true,
min: '',
model: "High_school",
styleClasses: ["half-width col-xs-12 col-sm-4", "job_title"]
}]
},
本地存储
// Loading the model from the localStorage
if(localStorage.getItem('model') !== null) this.model = JSON.parse(localStorage.getItem('model'));
// Saving the model to the localStorage
localStorage.setItem('model', JSON.stringify(this.model));
解决方案
推荐阅读
- javascript - 无限自动播放滑块 React js
- javascript - 在Angular中将毫秒格式化为dd:hh:mm:ss
- javascript - 错误: SMTPConnection._formatError 处的连接超时\n
- c++ - 必须仅使用 C++ 中的静态对象初始化 constexpr 引用吗?
- usbserial - CH340 具有用于柴油加热器和树莓派的自定义波特率
- authentication - 使用 Appium 的基本身份验证 Codeceptjs
- kubernetes - 如何导致单个 kubernetes pod 的有意重启
- javascript - 从下拉列表中选择后未加载 Json 文件
- java - 如何使按钮出现在双缓冲图像上?
- reactjs - 升级到 17.0.2 后,在 React.cloneElement 期间无法访问道具