vue怎么和后端对接
更新日期:2022-10-07 10:46:09
来源:互联网

我们在使用vue框架的时候,需要和后端完成对接才可以同步数据修改,那么vue怎么和后端对接数据呢,其实我们只要根据不同数据执行对应的命令就可以了。
vue怎么运行
方法一:
1、首先输入以下代码来获取数据:
this.$http.get('a.txt').then(function(res){
alert(res.data);
},function(res){
alert(res.status);
});
2、然后输入以下命令向服务器发送即可:(这里的a1、b2指的就是我们要发送的数据)
this.$http.get('a.php', {
a: 1,
b: 2
}).then(function(res) {
alert(res.data);
}, function(res) {
alert(res.status);
});
方法二:
1、我们也可以使用post来传递第三个或更多数据。
输入以下代码即可({emulateJSON: true}):
this.$http.post('a.php', {
a: 1,
b: 2
}, {
emulateJSON: true
}).then(function(res) {
alert(res.data);
}, function(res) {
alert(res.status);
});
有帮助
无帮助
- CPU天梯图2023年最新版2863417次
- 学习通网页版登录入口1419811次
- 微信红包封面序列号大全免费2023最新1088924次
- 显卡天梯图2023最新版(持续更新)782815次
- 微信号id名字大全641475次
- 百度网盘网页版登录入口620632次
- 百度网盘违规内容下载失败怎么办533880次
- 2022天梯排行榜492531次
- qq邮箱格式写法分享368720次
- xgp游戏列表2023年7月355025次
周
月