vue中调了接口之后拿不到后台返回的值(解决异步问题)


 1 getOperatorList () {
 2   request({
 3         headers: {
 4           'Content-Type': 'application/json'
 5         },
 6         url: baseUrl + '/project/operator/getOperator',
 7         method: 'POST',
 8         timeout: 300 * 1000
 9       }).then((res) => {
10         this.operators = []
11         if (res.data.success) {
12           // this.$message.success(res.data.desc);
13           this.operatorInfo = res.data.data
14     }else {
15     this.$message.error(res.data.desc)
16    }
17 }
1 async createMysql () {
3   await this.getOperatorList()
4   console.log(this.operatorInfo) // 有值
6 }
1 1 createMysql () {
2 3   this.getOperatorList()
3 4   console.log(this.operatorInfo) // 无值
4 6 }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM