我是 Vue 和 Bootstrap Vue 的新手。我構(gòu)建了一個(gè)使用 API 數(shù)據(jù)數(shù)組的表。<b-modal>該表有一個(gè)在子組件中打開(kāi)的按鈕。該模式具有三個(gè)字段,通過(guò)單擊按鈕將數(shù)據(jù)附加到表的數(shù)組中。然后該表會(huì)更新。到這里為止就好了。問(wèn)題是:當(dāng)我嘗試從 推送更多信息時(shí)<b-modal>,我之前從 添加的信息<b-modal>在數(shù)組和表中都被修改。從API帶來(lái)的信息沒(méi)有被修改。怎么了?多謝。Vue.component('modal', { props:['commodity_data'], template:/*html*/` <div> <b-modal id="addModal" ref="modal" hide-footer title="Add Commodity"> <b-form-group> <label> Hu Count <b-form-input id="hu_count" v-model="new_row.hu_count" > </b-form-input> </label> <label> Dimensions <b-form-input id="dimensions" v-model="new_row.dimensions" > </b-form-input> </label> <label> Weight <b-form-input id="weight" v-model="new_row.weight" > </b-form-input> </label> </b-form-group> <b-button variant="success" @click="addRow">Add Row</b-button> </b-modal> </div> `, data(){ return{ new_row: { dimensions: '', hu_count: '', weight: '', } } }, methods:{ addRow: function () { this.commodity_data.push(this.new_row) this.$refs.modal.hide() console.log(this.commodity_data); } }})
如何在 Bootstrap Vue 中將模態(tài)數(shù)據(jù)發(fā)送給父級(jí)?
開(kāi)心每一天1111
2023-11-11 21:00:44