在vue的methods,函数search作用是返回请求数据,但是报错search(options){consturl=this.isTeacher?'/api/search_Teacher':'/apis/org/search_student';constparams=options.ids?{ids:options.ids}:{keyword:this.keyword};returnthis.$http.get(url,{params}).then((response)=>{returnresponse.body;},(err)=>{console.log(err);})},但是不明白如何调用这个search,获取到data??尝试下面的方法,报错,this.searchisnotafunction??this.seach({ids:this.selected}).then((res)=>{if(!res)this.$message.error('搜索失败');elsethis.selectedData=res;});有没有好的方法,谢谢
2 回答
PIPIONE
TA贡献1829条经验 获得超9个赞
asyncsearch(options){consturl=this.isTeacher?'/api/search_Teacher':'/apis/org/search_student';constparams=options.ids?{ids:options.ids}:{keyword:this.keyword};try{constres=awaitthis.$http.get(url,{params})returnres.body}catch(e){console.log(e)}},useconstdata=awaitthis.search({ids:this.selected})if(!data)this.$message.error('搜索失败');elsethis.selectedData=data;
添加回答
举报
0/150
提交
取消