赞
踩
**
一般小型项目直接通过cdn引用vue.js,使用axios时,需要配合qs使用
CDN引入:
Axios :
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
Qs:
<script src="https://cdn.bootcss.com/qs/6.5.1/qs.min.js"></script>
getuser: function() {
this.user.useruid = '111';
this.user.password = '123456';
var self = this;
/*使用JSON.parse将对象格式化为json形式*/
var userdata = JSON.parse(JSON.stringify(self.user));
axios.post('http://localhost:18094/login/getUseraxios', userdata)
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
});
},
**
postparams: function() {
var param = new URLSearchParams();
param.append('userid','111');
param.append('password','123456');
axios.post('http://localhost:18094/login/getUser',param)
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
});
},
postparams: function() {
axios.post('http://localhost:18094/login/getUser',Qs.stringify({
'userid':'111',
'password':'123456'
}))
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
});
},
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。