首页 > 解决方案 > 登录用户的本地存储问题

问题描述

这里我使用本地存储。这里的用例是在我们的站点中,我们有两个用户,一个是企业用户,另一个是个人用户。所以这里是个人用个人用户登录,然后所有填充的值都保存在本地存储中,同一个用户用他的商业用户邮件登录,然后我正在使用之前填写的个人登录相同的值。所以我们不想显示在个人用户中不应该显示在商业用户中的值,所以如何实现这一点请帮助我本地存储两个不同的登录名,使用相同的邮件和相同的用户,但登录名是企业和个人

图式

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));

标签: vue.js

解决方案


推荐阅读