vue | vue cookie expires
AVue.jspluginformanipulatingcookiestesteduptoVuev2.0.5InstallationInstallthroughnpmnpm install vue-cookie --save Includein
afterloadingVueanditwillautomaticallyhookintoVue Ordoitthecoolwayandloaditinyourmain.js/app.jsvar Vue = require(vue);var VueCookie = require(vue-cookie);Vue.use(VueCookie); UsageThepluginisavailablethroughthis.$cookieincomponentsorVue.cookieRatherthanimplementingmyownCookiehandling...A Vue.js plugin for manipulating cookies tested up to Vue v2.0.5
InstallationInstall through npm
npm install vue-cookie --save
Include in <body> after loading Vue and it will automatically hook into Vue
<script src="/node_modules/vue-cookie/build/vue-cookie.js"></script>
Or do it the cool way and load it in your main.js/app.js
var Vue = require(vue);
var VueCookie = require(vue-cookie);
Vue.use(VueCookie);
Usage
The plugin is available through this.$cookie in components or Vue.cookie
Rather than implementing my own Cookie handling logic the plugin now wraps the awesome tiny-cookie[1] package
Examplethis.$cookie.set(test, Hello world!, 1);
this.$cookie.get(test);
this.$cookie.delete(test);
Advanced examples
this.$cookie.set(test, Random value, {expires: 1, domain: localhost});