VUE.JS 使用axios数据请求时数据绑定时 报错 TypeError: Cannot set property 'xxxx' of undefined 的解决办法
正常情况下在data里面都有做了定义

在函数里面进行赋值

这时候你运行时会发现,数据可以请求到,但是会报错 TypeError: Cannot set property 'listgroup' of undefined
主要原因是:
在 then的内部不能使用Vue的实例化的this, 因为在内部 this 没有被绑定。
可以看下 Stackoverflow 的解释:
解决办法:
1、用ES6箭头函数,箭头方法可以和父方法共享变量

2、在请求axios外面定义一下 var that=this

问题解决
VUE.JS 使用axios数据请求时数据绑定时 报错 TypeError: Cannot set property 'xxxx' of undefined 的解决办法的更多相关文章
- VUE - 使用axios数据请求时数据绑定时 报错 TypeError: Cannot set property 'xxxx' of undefined 的解决办法
created() { var that=this axios.get('http://jsonplaceholder.typicode.com/todos') .then( ...
- 使用webpack命令打包时,报错TypeError: Cannot read property 'presetToOptions' of undefined的解决办法
我只安装了webpack,没有安装webpack-cli,第一次输入webpack打包时,提示 One CLI for webpack must be installed. These are rec ...
- vue报错TypeError: Cannot read property 'protocol' of undefined
错误信息如下所示: isURLSameOrigin.js?3934:57 Uncaught (in promise) TypeError: Cannot read property 'protocol ...
- vue表单校验提交报错TypeError: Cannot read property 'validate' of undefined
TypeError: Cannot read property 'validate' of undefined at VueComponent.submitForm (plat_users.html: ...
- vue报错TypeError: Cannot read property '$createElement' of undefined
报错截图: 这个错误就是路由上的component写成了components
- Node.js报错TypeError: Cannot read property 'isDirectory' of undefined
截图如下: 原因如下:记住"./uploads" 后要加一个/ fs.stat("./uploads/" + files[i], function(err, s ...
- 抓取https网页时,报错sun.security.validator.ValidatorException: PKIX path building failed 解决办法
抓取https网页时,报错sun.security.validator.ValidatorException: PKIX path building failed 解决办法 原因是https证书问题, ...
- JS报错:Cannot read property 'type' of undefined
在做图片上传功能的时候,遇到了JS无法识别图片type的问题,在使用过程中是没有问题的,但是不知道为什么浏览器的Console报这个错误: Uncaught TypeError: Cannot rea ...
- Vue使用Typescript开发编译时提示“ERROR in ./src/main.ts Module build failed: TypeError: Cannot read property 'afterCompile' of undefined”的解决方法
使用Typescript开发Vue,一切准备就绪.但npm start 时,提示“ ERROR in ./src/main.tsModule build failed: TypeError: Cann ...
随机推荐
- 真正的Maven经常使用命令
长期用Eclipse的Maven插件的小伙伴可能接触Maven的经常使用命令比較少.每次用每次翻文档. 假设让你脱离Eclipse怎么办,面试的时候考到了怎么办-- 假设你不想尴尬,请小朋友花点时间运 ...
- day1-pycharm使用
1.Ctrl+滑轮 字体大小 2.改变字体大小 3.开头模板 4.多行注释 ctrl+? 5.切换Python版本解释器
- node.js之十大Web框架
之前接触过Node.js是因为好奇大前端越来越能干了,连我后台的饭碗都要抢了,太嚣张了,于是我想打压打压它,然后就这样接触它了.再到后来是因为Settings-Sync插件二次开发,我需要用node. ...
- p1012拼数题解
#include<iostream> #include<algorithm> using namespace std; bool cmp(string b,string a) ...
- 开源版本PowerShell Core 6.2 发布
导读 PowerShell Core 6.2 GA 已发布,PowerShell Core 是 PowerShell 的开源版本,适用于 Linux,macOS 和 Windows. 有关 Power ...
- Elastic 今日在纽交所上市,股价最高暴涨122%。
10 月 6 日,Elastic 正式在纽约证券交易所上市,股票代码为"ESTC".开盘之后股价直线拉升,最高点涨幅达122%,截止到收盘涨幅回落到94%,意味着上市第一天估值接近 ...
- Item 21: 比起直接使用new优先使用std::make_unique和std::make_shared
本文翻译自modern effective C++,由于水平有限,故无法保证翻译完全正确,欢迎指出错误.谢谢! 博客已经迁移到这里啦 让我们先从std::make_unique和std::make_s ...
- 未安装Oracle客户端的服务器上,使用ASP.NET远程连接Oracle
公司服务器一直都是使用 .NET+SQLSERVER的开发方式,有个项目需要进行读取远程Oracle的需求.由于oracle 基本不会,也是一边做一遍摸索. 首先是使用工具测试是否已经联通,因为之前用 ...
- maven新建项目
选择新建maven project 这个文件通常作为父工程,用于管理jar包的依赖,锁定jar包版本 选择next group id :如表面意思 组织名 公司名 artifact id :工 ...
- CPU-bound(计算密集型) 和I/O bound(I/O密集型)
概念 概念I/O系统,英文全称为“Input output system”,中文全称为“输入输出系统”,由输入输出控制系统和外围设备两部分组成,是计算机系统的重要组成部分.在计算机系统中,通常把处理器 ...