使用的 iView Select 組件,組件有一個方法: clearSingleSelect() . 調(diào)用方法為 this.$refs.nameSelect.clearSingleSelect(), 經(jīng)過測試正常使用是沒問題的?,F(xiàn)在想要在 render 函數(shù)里調(diào)用, 一直獲取不到 this.$refs.nameSelect ,報 undefined相關(guān)代碼h('Select', { ref: 'nameSelect', props: { transfer: true, clearable: true,
}, on: { 'on-change': (value) => { if (value === 'CLEAR') { this.$refs.nameSelect.clearSingleSelect()
}
},
},
}, this.assembleOptions(h, this.options))怎樣在 Render function 里面使用 $refs 呢?補充:this 指向是沒問題的,log(this.$refs) 能看到其他直接在 template 里的寫好的組件的 ref . 感覺問題應(yīng)該是當(dāng) render 函數(shù)把 Select 組件渲染以后,this.$refs 沒有動態(tài)更新。 所以報 undefined ,有沒有手動去更新 this.$refs 的方法,或者直接獲取到 render 函數(shù)渲染出來的實例的方法?
Vue 里怎樣在 Render 中使用 $refs
寶慕林4294392
2018-12-16 09:16:43