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:的错误的更多相关文章

  1. [Angular] ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'name' of undefined

    在数据请求完成通过 ionViewDidLoad 展示页面的时候 报错误 : ERROR Error: Uncaught (in promise): TypeError: Cannot read pr ...

  2. Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol')

    Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol') 报错信 ...

  3. 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 ...

  4. 关于 promise 吃到错误的理解

    关于 promise 吃到错误的理解 下面的内容需要对浏览器原生支持的 promise 的基本用法有了解,如果你还不知道 promise 和 promise 的 catch 方法,你可能需要先在 这里 ...

  5. 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 ...

  6. axios请求报Uncaught (in promise) Error: Request failed with status code 404

    使用axios处理请求时,出现的问题解决 当url是远程接口链接时,会报404的错误: Uncaught (in promise) Error: Request failed with status ...

  7. Uncaught (in promise)

    Uncaught (in promise) 使用es6的promise时候,有时候会出现如下错误: 这是因为,使用定义promise方法的时候,reject了,但是,在使用的地方没有用catch进行接 ...

  8. vue报错vue-router.esm.js?8c4f:2007 Uncaught (in promise) NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated"}

    今天在写vue项目配置好路由点击菜单时,突然在控制台报错. 错误信息如下: Uncaught (in promise) NavigationDuplicated {_name: "Navig ...

  9. 解决"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 ...

随机推荐

  1. Java基础中一些容易被忽视的语法小细节总结

    一:语法细节 1. Java中的命名规则: package:统一使用小写字母 class:首字母大写,使用驼峰标识 method:首字母小写,使用驼峰标识 field:首字母小写,使用驼峰标识 sta ...

  2. python 字符串 字节

    字符串 字节   a. 字符串转字节 1 2 key = "xxxx" bkey = bytes(key,encoding='utf-8') b. bytearray 数组 1 2 ...

  3. asp.net core 六 Oracle ORM

         .netcore 中 Oracle ORM      在真正将项目移植到.netcore下,才发现会有很多问题,例如访问Oracle,问题出现的时间在2017年底          参考连接 ...

  4. scrapy爬取西刺网站ip

    # scrapy爬取西刺网站ip # -*- coding: utf-8 -*- import scrapy from xici.items import XiciItem class Xicispi ...

  5. 关于阮大神的es6标准入门第一章

    题记:之前在10月份的时候写过阮大神的es6的第一章,但是由于那段时间项目组的动荡,所以也没有什么后续,导致我现在对es6基本都忘的差不多了,不过,现在换了新公司,最近也没什么任务,所以现在开始重新写 ...

  6. Python3玩转儿 机器学习(3)

    机器学习算法可以分为: 监督学习 非监督学习 半监督学习 增强学习 监督学习:给机器的训练数据拥有"标记"或者"答案",例如: 我们需要告诉机器左边的画面是一只 ...

  7. POJ 1721 CARDS

    Alice and Bob have a set of N cards labelled with numbers 1 ... N (so that no two cards have the sam ...

  8. permu(变态考试题)

    题目描述 给定一个严格递增的序列T,求有多少个T的排列S满足:∑min(T[i],S[i])=k 输入输出格式 输入格式: 第一行两个数n,k 第二行n个数,表示T 输出格式: 一个正整数表示答案,答 ...

  9. ●HDU 3689 Infinite monkey theorem

    题链: http://acm.hdu.edu.cn/showproblem.php?pid=3689题解: KMP,概率dp (字符串都从1位置开始) 首先对模式串S建立next数组. 定义dp[i] ...

  10. UVA11404:Palindromic Subsequence

    回文子串dp,最小字典序的话需要记录一下,注意是string型的,不能只记录一个字符,因为可能出现相等的情况 #include<cstdio> #include<cstdlib> ...