VUE开发笔记
程序员文章站
2022-06-19 09:22:15
1、GET单个参数请求示例//跨域配置代码段proxyTable: { "/apis": { target: "http://pv.sohu.com", secure: false, changeOrigin: true, pathRewrite: { "^/apis": "" } }, "/api": { target: "http://local...
1、GET单个参数请求示例
//跨域配置代码段
proxyTable: {
"/apis": {
target: "http://pv.sohu.com",
secure: false,
changeOrigin: true,
pathRewrite: {
"^/apis": ""
}
},
"/api": {
target: "http://localhost:9001/api",
secure: false,
changeOrigin: true,
pathRewrite: {
"^/api": "/"
},
},
},
//vue.js代码片段
agetClick(){
let paramss= {
count: 100
}
axios
.get("api/Visit/RequestGET", {paramss}, {
timeout: 1000
})
.then(res => {
this.$message({
message: res,
type: "success"
});
})
.catch(ex => {
/*
if ((ex.data.ErrMsg == null) | (res.ErrMsg == "")) {
res.ErrMsg = "发送失败";
}*/
this.$message({
message:"异常信息",
type: "error"
});
});
},
2、POST请求
//混合参数请求
let para = [
{
TaskNo: getGuidGenerator(),
Params: [{ Name: "wait_state", Value: "2" }]
}
];
// "继续下送货任务
axios
.post("http://10.177.104.69:9999/api/fms/addTask", para)
//单个实体类型参数请求示例
agetClick(){
let visit = {
id: 0,
cip: "192.168.5.999",
cid: 320500,
cname: "江苏省苏州市",
updatetime: "2016-6-6",
amount: 1,
equipment: "Goole Chrome",
system: "Windows10",
}
axios
.post("api/Visit/SetVisit", visit)
.then(res => {
this.$message({
message: res.data,
type: "success"
});
})
.catch(ex => {
this.$message({
message:"异常信息",
type: "error"
});
});
},
3、vue定义全局变量和全局方法【https://segmentfault.com/a/1190000015842187】
4、统计网站访问IP信息【https://www.cnblogs.com/JimShi/p/11302384.html】
5、统计网站页面访问量、vue项目中统计页面访问量PV UV【https://www.jianshu.com/p/395650e6b5b2】
本文地址:https://blog.csdn.net/Elegant_Kevin/article/details/110675152
上一篇: 小米手环2怎么设置支付宝免密支付?