vue-cookies主要是用於登錄的應用。
由於vue自己不帶,所以需要自己安裝依賴。安裝步驟如下:
1.npm install vue-cookies --save
可參考npm 官方地址:https://www.npmjs.com/package/vue-cookies
設置完成之后,可能還會碰到一個問題,vue請求時無法攜帶cookie?
在請求的地址后面加個東東就好了。代碼如下:
that.$http.jsonp("http://XXXXXXXXXX",{withCredentials:true}).then(function(response){ console.log(response); });
withCredentials:true ==>就是它了。
ok,收工。