vue resource 携带cookie请求 vue cookie 跨域(六)

1、依赖VueResource  确保已安装vue-resource到项目中,找到当前项目,命令行输入:

        

 npm install vue-resource --save

在主方法添加 过滤

Vue.http.interceptors.push(function(request, next) {//拦截器
// 跨域携带cookie
 request.credentials = true;
next()
})

 

 

以下是针对每个请求都会携带cookie ,也可以指定接口请求携带cookie

 

this.$http.get('xxxx',{params: 参数对象,credentials: true})

 

示例下载

 

posted on 2017-07-05 19:05  爱拼才有钱  阅读(8052)  评论(0编辑  收藏  举报

导航