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 ...
随机推荐
- Mego开发文档 - 复杂保存操作
复杂保存操作 Mego框架还提供了更强大的数据更新API,以简化开发工作,同时也保证的性能. 指定属性添加数据 本列中指定插入一个数据对象,并且只会插入三列数据,最后两个属性是以表达式的形式插入. u ...
- istio入门(05)istio的架构概念2
- angular2 学习笔记 ( unit test 单元测试 )
第一次写单元测试. 以前一直都有听说 TDD 的事情. 今天总算是去尝试了一下. 先说说 TDD 的想法, 是这样的, 开发项目的流程 : 确定需求 -> 写类,接口,方法的名字(不写具体实现代 ...
- 阿里云API网关(5)用户指南(调用 API)
网关指南: https://help.aliyun.com/document_detail/29487.html?spm=5176.doc48835.6.550.23Oqbl 网关控制台: https ...
- Python 爬取淘宝商品信息和相应价格
!只用于学习用途! plt = re.findall(r'\"view_price\"\:\"[\d\.]*\"',html) :获得商品价格和view_pri ...
- multiprocessing.Process() ----------python中的多进程
python 当中 使用封装好的 multiprocessing 为我们实现创建多进程任务. 1 Process()方法创建子进程 使用multiprocessing.Process() 方法产生一个 ...
- String、StringBuffer、StringBulider之间的联系和区别
首先,我们大概总体的解释一下这三者的区别和联系 String的值是不可变的,这就导致每次对String的操作都会生成新的String对象,不仅效率低下,而且大量浪费有限的内存空间. StringBuf ...
- 云计算 IaaS,SaaS,PaaS的区别?一个通俗易懂的吃货文章
来自一篇吃货文章了: ———————————————————— <img src="https://pic2.zhimg.com/a55676f8e1b084a398f8cd5 ...
- 个人网站建设(适合Java初学者)(一)
概述 作为一个在八本学校在校生,没有实验室,也没有项目可做.一直想做一个个人博客,一年前学完javaweb之后做了一个简单的博客,ui惨不忍睹就算了,还有各种bug.酝酿了很久,寒假用了将近一个月时间 ...
- hdu-3348 coins---贪心
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3348 题目大意: 给你一个价格,还有面值分别为1,5,10,50,100(单位:毛)纸币的数量,要你 ...