第一步:vue项目request.js 加
// ajax请求默认带上cookie
axios.defaults.withCredentials=true;
第二步:后台接口处理:
public/index.php加:
// 支持事先使用静态方法设置Request对象和Config对象
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:GET,POST,PUT,DELETE,PATCH,OPTIONS');
header('Access-Control-Allow-Headers:Content-Type, X-ELEME-USERID, X-Eleme-RequestID, X-Shard,X-Shard, X-Eleme-RequestID,X-Adminid,X-Token');