logo
  • 教程列表
  • SO官方文档
  • 在 Vue 中使用它
    • 错误使用箭头函数定义引用此方法的方法
    • RIGHT 使用典型的函数语法定义方法
    • 错误在 Vue 方法内部的回调中使用它
    • 正确使用闭包来捕获它
    • 右使用箭头函数
    • 正确使用 bind
    • 错误在承诺中使用这个
  1. StackOverflow 文档
  2. Vue.js 教程
  3. 在 Vue 中使用它
  4. 错误在承诺中使用这个

错误在承诺中使用这个

Created: November-22, 2018

new Vue({
  el:"#star-wars-people",
  data:{
    people: null
  },
  mounted: function(){
    $.getJSON("http://swapi.co/api/people/", function(data){
      // Again, this is wrong! "this", here, refers to the window.
      this.people = data.results;
    })
  }
})
  • 正确使用 bind

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明