Installation
CNPM I Axios--save-dev
Global referencing in Project Main.js
from " Axios " vue.prototype. $http=axios;
You can then pass this in the project. $http used, then function indicates successful response, catch indicates failure
This . $http ({ URL:"https://api.api68.com/klsf/getLotteryInfo.do?issue=&lotCode=10009 ", type:"get" }) . Then (res) =>{ Console.log (res); }) . Catch (err) ={ console.log (err) })
If the callback function in then and catch is not an arrow function, you can use. Bind (this) to resolve the problem of accessing this instance inside the function
This . $http ({ URL:"https://api.api68.com/klsf/getLotteryInfo.do?issue=&lotCode=10009 ", type:"get" }) . Then (function (res) { Console.log (res); Console.log (this. msg); }. Bind (this)) . Catch (function (err) { console.log (err) }.bind (this)) }
Using Axios in a Vue project