我的模版中有一个模态
<loading-modal:modal-state="openAddProductsModal.state" title="Add New Products" size="lg" >
<add-product ref="addProduct" :@has-errors="openAddProductsModal.errors = $event" :"/>
<div slot="footer">
<btn @click="$set(openAddProductsModal, state, false)">Cancel</btn>
<btn :disabled="openAddProductsModal.errorAdd " type="primary" @click="save()">
Save
</btn>
</div>
</loading-modal>
我也有这样的计算属性:
computed: {
openAddProductsModal: {
get() {
this.errorAdd = true;
return {state: this.$route.query.modal == 'open', errors: this.errorAdd}
},
set(newValue) {
this.errorAdd = newValue.errors
ModalState.setModalState(newValue.state, this.$route, this.$router, 'open')
}
},
}
我想通过单击属性Cancel
上的按钮state
进行更改,但似乎不起作用-我也尝试过使用this.$set
。如何通过单击按钮来调用setter方法?