nuxt服务端操作cookie

1、npm i -S cookie-universal-nuxt
2、nuxt.config.js
    modules: [
        'cookie-universal-nuxt'
    ]
3、使用
    * 服务端(store/index.js)
        const actions = {
            // nuxt提供的,每次刷新页面都会执行此函数,参数1为store,参数2为context。(只能在index.js中)
            nuxtServerInit({commit}, {app}) {
                app.$cookies.get('key')
            }
        }
    * 客户端
        mounted() {
            this.$cookies.set('key', 'value', {
                maxAge: 60 * 60 * 24 * 7  // 单位秒
            })
        }
原文地址:https://www.cnblogs.com/linding/p/14576949.html