发送异步请求
var url = 路由路径
axios.get(url, {
responseType:数据类型
})
.then((response => {})
.catch(error => {})
''' 示例代码 '''
var url = this.host + '/usernames/' + this.username + '/count/';
axios.get(url, {
responseType: 'json'
})
.then(response => {
if (response.data.count > 0) {
this.error_name_message = '用户名已存在';
this.error_name = true;
} else {
this.error_name = false;
}
})
.catch(error => {
console.log(error.response);
})
|
|