鍍金池/ 問答/HTML/ vue中,綁定計(jì)算屬性出錯(cuò)

vue中,綁定計(jì)算屬性出錯(cuò)

html

<input :type="inputType"
       :id="getId()"
       :name="getId(false)"
       :class="inputType"
       :value="item.propertyValueId"
       @click="handleCheck"
       v-model="checkedIdList"
       v-validate="{
            required: attribute.required
       }"/>
<label :for="getId(false)" :title="item.valueData" class="ell">{{ item.valueData }}</label>
 
 props: {
    // 已經(jīng)選中的列表
    checkedList: {
        type: [Array, Number] ,
        default: function () {
            // return []
        }
    }
},

同時(shí)使用計(jì)算屬性:
checkedIdList: {
    get() {
        return this.checkedList
    },
    set(val) {
        this.checkedIdList = val
    }
},
這樣就造成死循環(huán)了超出內(nèi)存會(huì)溢出出錯(cuò),請問怎么綁定?
回答
編輯回答
近義詞

你在一個(gè)屬性的的setter里邊又get了一遍這個(gè)屬性,當(dāng)然會(huì)堆棧溢出了。。。

checkedIdList: {
    get() {
        return this.checkedList
    },
    set(val) {
        this.checkedIdList = val
    }
}
2017年6月15日 07:44
編輯回答
落殤

請問您想要實(shí)現(xiàn)什么呢?v-model不是已經(jīng)實(shí)現(xiàn)了雙向綁定?

2018年1月16日 10:56