1.安装cookie-nuiversal-nuxt
```
npm install cookie-nuiversal-nuxt --save --registry=https://registry.npm.taobao.org
```
2.配置nuxt.config.js
```
modules:[
'cookie-nuiversal-nuxt'
]
```
.3.使用
```
this.$cookies.set('user',[])
this.$cookies.get('user')
this.$cookies.remove('user')
```
4.登录跳转
```
if(!this.$route.query.path || /login/reg/.test(this.$route.query.path)){
this.$router.replace('/user')
}else{
this.$router.replace(this.$route.query.path)
}
```
5.页面刷新初始化vuex
```
export const actions = {
nuxtServerInit(store,{app:{$cookies}}){
let user = $cookies.get('user')
user = user?user:''
store.commit('user/asdds')
}
}
```
6.拦截器定义
```
$axios.onRequest(config=>{
config.headers.token = store.state.user.token
})
```