我要在父組件的computed中使用子組件的值,有什么辦法嗎?computed: { addButtonDisabled() { return this.$refs.queryBox.selectSportsType === _const.ALL_SELECTION }, 報(bào)錯(cuò),Error in render: "TypeError: Cannot read property 'selectSportsType' of undefined"百度了下computed: { addButtonDisabled() { this.$nextTick(()=>{ return this.$refs.queryBox.selectSportsType === _const.ALL_SELECTION }) }, 這樣才可以獲取到可是這樣又沒辦法用computed了,請問有什么解決辦法嗎,謝謝目前的寫法,父組件聲明要用的值addButtonDisabled傳給子組件,子組件內(nèi)修改,下部分為子組件代碼computed: { addButtonDisabledProp(){ return this.selectSportsType === _const.ALL_SELECTION || this.selectParticipantType === _const.ALL_SELECTION }},watch:{ addButtonDisabledProp(){ this.$emit('update:addButtonDisabled', this.addButtonDisabledProp) }},
我要在父組件的computed中使用子組件的值,有什么辦法嗎?或者父組件使用子組件的
慕運(yùn)維8079593
2019-03-21 18:19:38