{
"/api": {
"target": "http://192.168.1.114:8041/", // 代理的地址
"secure": false,
"pathRewrite": {"^/api": ""}
}
}
複製代碼
ng serve --open
前端
// ajax數據測試 post
doPost() {
const obj = {
LogID: 'zhangabo',
OldPwd: '123456',
NewPwd: '123456'
};
this.http.doPost('api/ActionApi/UserInfo/ChangePassword', obj).subscribe((data: any) => {
console.log(data, 'post請求');
});
}複製代碼
這樣就完成了angular前端跨域ajax