一、依賴VueResource 確保已安裝vue-resource到項目中,找到當前項目,命令行輸入:
npm install vue-resource --save
在主方法添加 過濾vue
Vue.http.interceptors.push(function(request, next) {//攔截器 // 跨域攜帶cookie request.credentials = true; next() })
如下是針對每一個請求都會攜帶cookie ,也能夠指定接口請求攜帶cookie
this.$http.get('xxxx',{params: 參數對象,credentials: true})
npm