vue-sessionstorage

Install

npm install --save vue-sessionstorage

 main.js

import VueSessionStorage from 'vue-sessionstorage'
Vue.use(VueSessionStorage)

 方法

this.$session.get(key)


this.$session.set(key, value)


this.$session.exists(key)


this.$session.remove(key)


this.$session.clear(key)

 实例

 

export default {
    name: 'login',
    methods: {
        doLogin() {
            axios.post('/login', {...}).then(response => {
                let username = response.data.username;
                this.$session.set('username', username); // Set the username in session Storage
            });
        }
    } 
    
}

 

你可能感兴趣的:(vue.js)