第一步:

npm install axios              // 安装axios

第二步 :

在 main.js 引入 

// axios

import axios from "axios";

Vue.prototype.$axios = axios;  //此处根据项目情况来配置

第三步:

在页面中调用

created() {
    this.$axios
      .get("http://wthrcdn.etouch.cn/weather_mini?city=郑州")
      .then(function(response) {
        console.log(response.data.data);
      })
      .catch(function(error) {
        console.log(error);
      });
  },

end :有用的话请点个赞!转发请注明原文章地址,谢谢配合!

 

Logo

前往低代码交流专区

更多推荐