vuecli使用axios
程序员文章站
2022-07-02 15:34:26
...
1,安装axios
cnpm install axios --save
2,在需要的地方引入axios
import axios from 'axios'
3,调用接口测试
axios.get('http://192.168.1.111:8001/api/auth/GetTimeSpan', {
params: {
nonce:"62818576",
timestamp:"1533094681403",
token:"62818576",
signature:"163b010ce00cf8471e78df10bb111641"
}
})
.then(function (response) {
console.log(response);
})
.catch(function (response) {
console.log(response);
});
4,编程式调用
axios({
method:'post',
url:host+url,
responseType:'stream',
params:obj
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});