TypeError: Cannot read property 'get' of undefined, Axios, Vue.JS尝试使用 axios 从 api 访问获取请求时,我从 Vue 收到这个奇怪的错误,我收到 TypeErro...
尝试使用 axios 从 api 访问获取请求时,我从 Vue 收到这个奇怪的错误,
我收到 "TypeError: Cannot read property \\'get\\' of undefined"
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
<template>
{{ msg }} <p>Welcome to your new single-page application, built with Vue.js.</p> </template> var Vue = require('vue'); // import axios from"axios"; window.axios=require('axios'); export default { name: 'Home', props: { msg: String }, component: { }, mounted: function () { alert('Hi '); this.axios.get('https://api.github.com/users') .then(value => { alert(value); }); } }; <!-- Add"scoped" attribute to limit CSS to this component only --> <style scoped> </style> |
相关讨论
1
|
import axios from 'axios';
|
更有效的方法是在
1
|
Vue.prototype.$http = axios
|
并在任何你想要的地方使用它
沃梦达教程
本文标题为:关于 vuejs2:\\”TypeError: Cannot read property \\


基础教程推荐
猜你喜欢
- clientX,pageX,offsetX,x,layerX,screenX,offsetLeft区别分析 2024-01-08
- webpack学习笔记一:安装webpack、webpack-dev-server、内存加载js和html文件、loader处理非js文件 2023-10-29
- 创建Vue3.0需要安装哪些脚手架 2025-01-16
- Django操作cookie的实现 2024-04-15
- html5视频如何嵌入到网页(视频代码) 2025-01-22
- Loaders.css免费开源加载动画框架介绍 2025-01-23
- js判断一个对象是否在一个对象数组中(场景分析) 2022-10-21
- JSONObject与JSONArray使用方法解析 2024-02-07
- 纯css实现漂亮又健壮的tooltip的方法 2024-01-23
- Bootstrap学习笔记之css组件(3) 2024-01-22