【发布时间】:2020-03-08 11:22:02
【问题描述】:
我无法使用“保存”方法来保存对表格数据的更改
我正在使用“cellValueChanged”方法来编辑和保存表格单元格。
<ag-grid-vue :cellValueChanged="save"></ag-grid-vue>
methods: {
save() {
const method = this.instituicao.id ? 'put' : 'post'
const id = this.instituicao.id ? `/${this.instituicao.id}` : ''
axios[method](`${baseApiUrl}/instituicao${id}`, this.instituicao)
.then(() => {
this.$toasted.global.defaultSuccess()
this.reset()
})
.catch(showError)
},
【问题讨论】:
-
你试过this.instituicao的console.log吗,似乎是未定义的
-
是的,我可以查看机构数据:mounted() { this.columnDefs = [ {headerName: 'ID', field: 'id', filter: false, editable: true}, { headerName:'Código do Banco',字段:'codigo',过滤器:false,可编辑:true},{headerName:'Nome do Banco',字段:'nome',过滤器:false,可编辑:true}]; axios.get(
${baseApiUrl}/instituicao) .then(({data}) => this.rowData = data) }, -
尝试使用 this.instituicao & instituicao.id
-
哪一行代码?
-
const 方法 = this.instituicao & instituicao.id? “放”:“发布”