我有两个名为 OrderComponent 和 ModalOrder 的组件(使用 vue-modal-js)
我将数据从 OrderComponent 传递到 ModalOrder,在 ModalOrder 中,我使用输入标签来包含 quantity_ordered 和按钮来增加它的值,如下所示
<!-- ModalOrder.vue -->
<input v-model="order.quantity_ordered" />
<button @click.prevent="increment"></button>
在我的脚本标签中
// ModalOrder.vue
<script>
export default {
name: "ModalOrder",
methods: {
beforeOpen (event) {
// if there's a data passed from the OrderComponent, I put it to "order" data
this.order = event.params
// if there's no data passed a.k.a a new record, I have to set the default value to 0
if (this.order.quantity_ordered == undefined) {
this.order.quantity_ordered = 0
}
},
...
increment() {
this.order.quantity_ordered += 1
// this method will not increment the input UI, if it's a new record
},
},
data() {
return {
order : {
code: '',
table_name: '',
customer_name: '',
employee_name: '',
menu_name: '',
quantity_ordered: ''
},
}
}
}
</script>
我的问题是每当我想制作新的订单数据时,当我单击按钮增加时,输入值 UI 不会增加
先感谢您。
Helenr
相关分类