logo
  • 教程列表
  • SO官方文檔
  • 在 Vue 中使用它
    • 錯誤使用箭頭函式定義引用此方法的方法
    • RIGHT 使用典型的函式語法定義方法
    • 錯誤在 Vue 方法內部的回撥中使用它
    • 正確使用閉包來捕獲它
    • 右使用箭頭函式
    • 正確使用 bind
    • 錯誤在承諾中使用這個
  1. StackOverflow 文件
  2. Vue.js 教程
  3. 在 Vue 中使用它
  4. 正確使用 bind

正確使用 bind

Created: November-22, 2018

你可以繫結回撥函式。

new Vue({
  el:"#star-wars-people",
  data:{
    people: null
  },
  mounted:function(){
    $.getJSON("http://swapi.co/api/people/", function(data){
      this.people = data.results;
    }.bind(this));
  }
})
  • 錯誤在承諾中使用這個
  • 右使用箭頭函式

Copyright © 2018. All right reserved

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

  • 關於本站
  • 免責聲明