vue-cookies
程序员文章站
2022-05-11 22:59:46
...
第一步:安装vue-cookies
npm install vue-cookies --save
第二步:引入和通过 Vue.use() 明确地安装
// require
var Vue = require('vue')
Vue.use(require('vue-cookies'))
// es2015 module
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
推荐阅读