Uncaught (in promise) TypeError:的错误
1、错误
创建一个vue实例,在data定义一些变量,如activityTime。
在methods里面用了axios发送请求。
在then的回调里使用this.activityTime
报错!
2、原因。then没有跟promise实例同步执行就会出现上述的错误。
axios的then(function(){
console.dir(this) //this->undefined
})
3、解决
可以用bind绑定this的指向当前vue的实例
axios的then(function(){
console.dir(this) //this->undefined
}.bind(this))
Uncaught (in promise) TypeError:的错误的更多相关文章
- [Angular] ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'name' of undefined
在数据请求完成通过 ionViewDidLoad 展示页面的时候 报错误 : ERROR Error: Uncaught (in promise): TypeError: Cannot read pr ...
- Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol')
Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol') 报错信 ...
- tinymce 出现 Uncaught (in promise) TypeError: ae(...).createObjectURL is not a function
需要引入两个JS文件:jQuery.tinymce.min.js 和 tinymce.min.js <script type="text/javascript" src=&q ...
- 关于 promise 吃到错误的理解
关于 promise 吃到错误的理解 下面的内容需要对浏览器原生支持的 promise 的基本用法有了解,如果你还不知道 promise 和 promise 的 catch 方法,你可能需要先在 这里 ...
- Atitit Uncaught (in promise) SyntaxError Unexpected token < in JSON at position 0
Atitit Uncaught (in promise) SyntaxError Unexpected token < in JSON at position 0 Uncaught (in ...
- axios请求报Uncaught (in promise) Error: Request failed with status code 404
使用axios处理请求时,出现的问题解决 当url是远程接口链接时,会报404的错误: Uncaught (in promise) Error: Request failed with status ...
- Uncaught (in promise)
Uncaught (in promise) 使用es6的promise时候,有时候会出现如下错误: 这是因为,使用定义promise方法的时候,reject了,但是,在使用的地方没有用catch进行接 ...
- vue报错vue-router.esm.js?8c4f:2007 Uncaught (in promise) NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated"}
今天在写vue项目配置好路由点击菜单时,突然在控制台报错. 错误信息如下: Uncaught (in promise) NavigationDuplicated {_name: "Navig ...
- 解决"Uncaught (in promise) Error: Navigation cancelled from "/" to "/login" with a new navigation"报错处理
Uncaught (in promise) Error: Navigation cancelled from "/" to "/login" with a ne ...
随机推荐
- 官网jquery压缩版引用地址:
3.1.1版本 <!DOCTYPE html> <html lang="en"> <head> <meta charset="U ...
- POJ-3723 Conscription---最大权森林---最小生成树
题目链接: https://vjudge.net/problem/POJ-3723 题目大意: 需要征募女兵N人, 男兵M人. 每征募一个人需要花费10000美元. 带式如果已经征募的人中有一些关系亲 ...
- hdu1568 Fibonacci---前4位
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1568 题目大意: 求斐波那契数列第i项的前四位.i<1e8 思路: 由于数据范围大,不可能打表 ...
- JSON定义
如果我们要在不同的编程语言之间传递对象,就必须把对象序列化为标准格式,比如xml,但更好的方法是序列化为JSON,因为JSON表示出来就是一个字符串,可以被所有语言读取,也可以方便地存储到磁盘或者通过 ...
- 减小APK大小
本篇文章翻译自Reduce APK Size 用户通常不会去下载体积过大的应用程序,特别是当自己的设备连接的是 2G/3G 或者按字节付费的网络.这篇文章描述了如何缩减 APK 的体积大小,以使得更多 ...
- 前端之旅HTML与CSS篇之a便签中放入其他块元素会撑大高度的原因
原因:a元素下有一个匿名文本,这个文本外有一个匿名行级盒子,它有的默认vertical-align是baseline的,而且往往因为上文line-height的影响,使它有个line-height,从 ...
- [LeetCode] Beautiful Arrangement 优美排列
Suppose you have N integers from 1 to N. We define a beautiful arrangement as an array that is const ...
- 分布式版本管理工具 git常用命令
Git global setup git config --global user.name "joey" git config --global user.email " ...
- Discuz!X 系列 HTTP_X_FORWARDED_FOR 绕过限制进行密码爆破
分析有个不对头的地方:http://wooyun.jozxing.cc/static/bugs/wooyun-2014-080211.html 后面再补 这个漏洞比较简单. 我们看到配置文件来./in ...
- sublime下让代码居中
sublime在默认情况下当屏幕写满后只能在底端进行输入,对于我这种强迫症患者来说总想着让代码居中显示,在自己查阅相关sublime配置后进行改动. 点击:preference → setting,进 ...