计算属性里
getOptions() {
let obj = this.screen.sortList[this.screen.currentIndex]
// 判断是升序还是降序
let value = obj.status==1? ‘asc’ : ‘desc’
return { [obj.key] : value}//[obj.key]对象里的key
},
methods里
async getData() {
const res = await this.$http.post('/goods/search', {
title: this.searchText,
page: this.page,
...this.getOptions//扩展运算符去掉对象的括号
})