class guangchang { constructor() { this.getClick() this.seek() } async seek(newKey) { var res = await indexService.tab({ thing_category: -1, page: 1, thing_type:newKey == undefined ? 1 : newKey//这里用三元运算符判断获取参数为空 为1 不为空 为2 }); console.log(res); // item($(".recommend"), res) } async getClick() { //获取输入框值 $(".items").onclick = () => { $(".content").style.display = "none" $(".content1").style.display = "flex" this.seek(2) } $(".itemf").onclick = () => { $(".content1").style.display = "none" $(".content").style.display = "flex" this.seek(1) } } } function getClick(params) { } new guangchang()