vue 中多接口请求时 按顺序执行接口使用await async
async getSelectOrg () {console.log('----1')return axiosPost('/api/uum/org/orglist', {accessToken: localStorage.token,option: true}).then(response => {this.options_...
·
async getSelectOrg () { console.log('----1') return axiosPost('/api/uum/org/orglist', { accessToken: localStorage.token, option: true}).then(response => { this.options_grade = [] if (response.data.data.length > 1) { this.options_grade.push({ value: '-1', label: '全部' }) this.formInline.organization = '-1' } else if (response.data.data.length === 1) { this.formInline.organization = response.data.data[0].orgCode } for (let i = 0; i < response.data.data.length; i++) { let tmp = {} tmp.value = response.data.data[i].orgCode tmp.label = response.data.data[i].orgName this.options_grade.push(tmp) } console.log('----2') }).catch(err => { console.log(err) }) }, async getSelect () { await this.getSelectOrg() console.log('----3') this.searchInfo() } }, mounted () { let that = this window.onresize = function () { // 定义窗口大小变更通知事件 // _this.screenWidth = document.documentElement.clientWidth // 窗口宽度 that.clientHeight = document.documentElement.clientHeight // 窗口高度 } this.getSelect() },
更多推荐
已为社区贡献3条内容
所有评论(0)