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 }
原文地址:https://www.cnblogs.com/huxiuxiu/p/13050474.html