首页 > 解决方案 > axios [Vue 警告] 中的 VueJS 错误:v-on 处理程序中的错误:“TypeError:this.axios.get(...).then(...).cache 不是函数”

问题描述

我在 Vue js 中有一个错误,当我使用 Axios 时出现错误: [Vue warn]: Error in v-on handler: "TypeError: this.axios.get(...).then(...).cache不是函数” 我无法解决这个问题。

从 main.js 导入 Axios:

import * as axios from "axios";
import VueAxios from "vue-axios";
Vue.use(VueAxios, axios);

当我在组件中使用 Axios 时:

 this.axios
 .get("https://api.github.com/users/" + this.username + "/repos")
 .then(response => {
      this.repos = response.data;
      console.log(response.data);
  })
  .cache(error => {
       this.error = true;
       console.log(error);
  });

标签: javascriptvue.jsaxios

解决方案


推荐阅读