通过Vue如何操作cookie呢
参考链接:https://www.jianshu.com/p/535b53989b39
第一步:安装vue-cookies
npm install vue-cookies --save(或者-S)
第二步:引入和通过 Vue.use() 明确地安装
// require
var Vue = require('vue')
Vue.use(require('vue-cookies'))
// es2015 module (es6)
import Vue from 'Vue'
import VueCookies from 'vue-cookies'
Vue.use(VueCookies)
设置一个cookie
this.$cookies.set(keyName, value[, expireTimes[, path[, domain[, secure]]]]) //return this
获取一个cookie
this.$cookies.get(keyName) // return value
删除一个cookie
this.$cookies.remove(keyName [, path [, domain]]) // return false or true , warning: next version return this; use isKey(keyname) return true/false,please
存在a cookie name?
this.$cookies.isKey(keyName) // return false or true
得到所有 cookie name
this.$cookies.keys() // return a array
$ cookies关键名称不能设置为['expires','max-age','path','domain','secure']