vue-resource

PPG007 ... 2021-12-25 Less than 1 minute

# vue-resource

# 安装 vue-resource

npm install vue-resource
1

# 使用 vue-resource

注册插件:

Vue.use(vueResource);
1

发起请求:

this.$http.get('http://localhost:90/api/getAllStudents').then(
          response => {
            console.log(response.data);
          },
          error => {
            console.log(error.message);
          }
      )
1
2
3
4
5
6
7
8

vue-resource 与 Axios (opens new window) 使用方法基本一致,发送请求要通过 $http 对象完成,但是 vue-resource 维护频率低,推荐使用 Axios。

Last update: December 25, 2021 14:08
Contributors: PPG007