vuecli使用axios

版权声明:企业站,小游戏制作 https://blog.csdn.net/qq947289507/article/details/81328303

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);
});

猜你喜欢

转载自blog.csdn.net/qq947289507/article/details/81328303