jquery 方法
$.ajax({
url: "http://moonsic.com:9015/use/userList",
type: "post",
data: {
id: 001,
},
xhrFields: {
withCredentials: true // 携带跨域cookie
},
success(res) {
res = JSON.parse(res);
if (res.success && res.data) {
} else {
console.error(res.retMsg);
}
},
error(err) {
console.log('出错');
console.log(err);
}
});
复制代码
axios 方法
import axios from 'axios'
import qs from 'query-string'
axios.defaults.withCredentials = true; // 携带跨域cookie
复制代码