async search (event) {
// 声明url变量
let url = ''
// 根据调用本方法Html元素 的ID,来选择发送axios请求的 url地址, (区分,初始页,上一页或者下一页的 url地址)
if (event.target.id === 'previous') {
url = this.previous
} else if (event.target.id === 'next') {
url = this.next
} else {
// 下面的写法可能用,但感觉很难受,有其它写法吗??--------------------------------------------------------------
url = 'group/?project_name=' + this.inputProjectName + '&sample_name=' +
this.inputSampleName + '&orderdate_gte=' + this.inputDateGte + '&orderdate_ite=' + this.inputDateIte + '&offset=' + 0
}
// 向后后端发送get请求,并返回数据对象 res
const { data: res } = await this.$http.get(url)
Vue axios 我的ur l写法很low, 自已都看的不舒服, 还有什么写法,
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
4条回答 默认 最新
- 李筱宝 2021-10-20 09:13关注
var a = { previous:this.previous, next:this.next, } const { data: res } = await this.$http.get(a[event.target.id] || "/group", { params: a[event.target.id] ? {} : { project_name: this.inputProjectName, sample_name: this.inputSampleName, orderdate_gte: this.inputDateGte, orderdate_ite: this.inputDateIte, offset: 0, })
有用望采纳
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 2无用
悬赏问题
- ¥15 多电路系统共用电源的串扰问题
- ¥15 slam rangenet++配置
- ¥15 有没有研究水声通信方面的帮我改俩matlab代码
- ¥15 对于相关问题的求解与代码
- ¥15 ubuntu子系统密码忘记
- ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
- ¥15 保护模式-系统加载-段寄存器
- ¥15 电脑桌面设定一个区域禁止鼠标操作
- ¥15 求NPF226060磁芯的详细资料
- ¥15 使用R语言marginaleffects包进行边际效应图绘制