zl程序教程

您现在的位置是:首页 >  前端

当前栏目

vue中 axios 基本使用

Vue 基本 Axios 使用
2023-09-27 14:27:48 时间
yran add axios

main.js-可以加上这些东西快速配置网络请求

import http from 'axios';
Vue.prototype.$http = http;

在其他的views加载的过程中执行网络请求

  mounted() {
    this.$http.get('/user?ID=12345')
        .then(function (response) {
          console.log(response);
        })
        .catch(function (error) {
          console.log(error);
        });
  }

 404因为没有这个路径。不过说明已经加载成功了