報錯原因:當(dāng)你在頁面中使用計v-model去改變計算屬性的值(我是在input組件中使用v-model和vuex的state中的數(shù)據(jù)進(jìn)行關(guān)聯(lián)),使用默認(rèn)的getter是會報錯的,需要提供一個setter吸祟。
computed: {
? ??inputVal: {
? ? ? ? // getter
? ? ? ? get() {
? ? ? ? ? ?????return?this.$store.state.inputVal
????????????},
? ? ? ? set(newValue) {
? ? ? ? ? ? ? ? this.$store.state.inputVal = newValue
????????????}
????}
}????????