需求:
后台请求的接口是从0页开始的,但是pagination是从1开始的,就是在点击pagination的第1页是后台转0
1首先在data里面定义为1,其他地方也是定义1
return {
formSearch: {
name: '',
phone: '',
page: 1,
size: 10
}
}
2.在接口这里去重新创建一个对象,进行浅拷贝
getSalesList () {
this.loading = true
setTimeout(() => {
this.loading = false
}, 20000)
let data = Object.assign({}, this.formSearch, {
page: this.formSearch.page - 1
})
Fetch.saleslist(data).then(res => {
this.loading = false
if (res.status === 200) {
let data = res.data.data
this.list = data.content
this.totalElementsData = +data.totalElements
} else {
this.$message({
message: res.data.message,
duration: 3000
})
}
})
},
也就是这个
let data = Object.assign({}, this.formSearch, {
page: this.formSearch.page - 1
})
嗯嗯嗯嗯 就是这样