Vue 整合Axios
本文最后更新于:2024年3月18日 凌晨
Vue 整合Axios
安装
1
| $ yarn add axios vue-axios
|
使用
1 2 3 4
| import axios from 'axios' import VueAxios from 'vue-axios'
Vue.use(VueAxios, axios)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <template> <div class="home"> {{ info } </div> </template> <script> export default { data: function () { return { info: null, }; }, mounted() { this.axios .get("https://api.coindesk.com/v1/bpi/currentprice.json") .then((response) => (this.info = response)); }, }; </script>
|