javascript - 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);
});
解决方案
推荐阅读
- python-3.x - 服务器关闭时客户端请求卡住
- javascript - 如果里面的图像不存在,则隐藏一个部分
- python - 无法从相同/其他目录中的脚本导入模块
- angularjs - 使用 Angular 使网站中的管理员只能访问
- arrays - 计算两个一维数组的成对元素
- amazon-web-services - 使用 AWS Amplify iOS 接收消息以便正确触发 onNotification 事件的 APNS 消息结构是什么?
- python - 代码仅打印出搜索的第一项而不是所有项
- wpf - 如何阻止在 DotNetBrowser 中加载远程内容?
- leaflet - Displaying styles stored in a GeoJson File and making lines appear as lines instead of markers
- ansible - 避免在 Ansible Tower 或 AWX 中为工作流制作大量模板