alfhen / vue-cookie

A Vue.js plugin for manipulating cookies
MIT License
822 stars 72 forks source link

Vuex integration method #41

Open alexander-girsh opened 6 years ago

alexander-girsh commented 6 years ago

Hi there, this plugin is comfy (thank you, mr. Alfhen) , but if you want to incapsulate smth in vuex store (for example the choice between cookie and local storage), you may have an issue: from-the-box vuex doesn't know about this.$cookie or vm.$cookie.

All u need is just reinitialize that. Look on the pictures. vuex store app call

MauricioHernanCabrera commented 6 years ago

I had the same problem

ezra-obiwale commented 5 years ago

@noguilty4you @MauricioHernanCabrera Another option is to just use vue.prototype.$cookie directly.

import vue from 'vue'

async someAction ({ commit }) {
  // Do something
  vue.prototype.$cookie.set(key, value)
}
alexander-girsh commented 5 years ago

@noguilty4you @MauricioHernanCabrera Another option is to just use vue.prototype.$cookie directly.

import vue from 'vue'

async someAction ({ commit }) {
  // Do something
  vue.prototype.$cookie.set(key, value)
}

thanks, vue.prototype is interesting syntax