iT邦幫忙

0

vue element ui 的 ref 怎麼帶到子元件?

父元件

<el-table
      ref="orderTable"
      ...
      
      <hoursDialog :qch="qch"></hoursDialog>

子元件 method

toggleAllSelection(row) {
      this.$refs.orderTable.toggleAllSelection()
    },

這樣的情況下
在子元件觸發 toggleAllSelection 事件時會錯誤找不到
請問可以怎麼帶到子元件去?

froce iT邦大師 1 級 ‧ 2020-07-14 13:18:23 檢舉
子元件要用父元件的方法應該要用$emit發射出來之後處理吧?
你可以在子元件用 this.$parent 來存取父元件,但不推薦這樣用。
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答