鍍金池/ 問(wèn)答/Python  HTML/ 改變vue組件庫(kù)中的this指向

改變vue組件庫(kù)中的this指向

使用的是iview的組件庫(kù),如下為vue的methods屬性中一個(gè)方法

exit() {
      this.$Modal.confirm({
        title: '退出登錄',
        content: '是否確認(rèn)退出當(dāng)前登錄賬號(hào)',
        onOk() {
          console.log(this)
        }
      })
    },

現(xiàn)在this指向 this.$Moda;如何將this的指向vue實(shí)例

回答
編輯回答
心上人

exit() {

that.$Modal.confirm({
    title: '退出登錄',
    content: '是否確認(rèn)退出當(dāng)前登錄賬號(hào)',
    onOk:()=> {
      console.log(this);
    }
  })
}
2017年2月23日 11:16
編輯回答
離殤
exit() {
    var that = this;
    that.$Modal.confirm({
        title: '退出登錄',
        content: '是否確認(rèn)退出當(dāng)前登錄賬號(hào)',
        onOk() {
          console.log(that);
        }
      })
    }

希望我的回答能幫到您!

2017年2月1日 21:02