Uncaught (in promise) TypeError:的错误
2017-05-19 11:02
344 查看
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))
创建一个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: Super expression must either be null or a function
- ionic3+angular4中给DOM添加监听事件后报错:Uncaught (in promise): TypeError: Cannot read property 'addEventListen
- Uncaught (in promise) TypeError: __webpack_require__.i(...) is not a function
- 【Angular2】Uncaught (in promise): TypeError: Cannot read property 'id'
- laydate 日期格式为yyyy 或yyyy-MM时,出现错误Uncaught TypeError: Cannot read property 'length' of undefined
- Uncaught TypeError: Cannot use 'in' operator to sea
- Error 1 Inconsistent accessibility: parameter type 编译错误
- php错误 Fatal error: Cannot use object of type stdClass as array in……
- 关于 Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause() 错误
- Error 1 Inconsistent accessibility: parameter type 编译错误
- Uncaught TypeError: Cannot set property 'f7View' of undefined 错误原因
- jquery中Uncaught TypeError: $(...).ajaxUpload is not a function(…)错误解决方法
- js中出现TypeError: invalid 'in' operand a的错误解决
- 解决关于 ionic3 启动白屏 控制台错误提示:Uncaught SyntaxError Use of const in strict mode.
- jquery each报 Uncaught TypeError: Cannot use 'in' operator to search for错误
- jquery 的一个诡异错误“Uncaught TypeError: Object # has no method 'toLowerCase'”
- Uncaught TypeError: Cannot set property 'display' of undefined错误
- javascript位置错误导致Uncaught TypeError: Cannot read property 'elements' of null
- js错误Uncaught TypeError: $(...).datagrid is not a function自己写的并没有错但是一直报这个错(详解)
- 错误:Uncaught TypeError: Cannot read property 'WebSocket' of undefined