念汐
念汐
  • 发布:2022-10-13 22:29
  • 更新:2022-10-14 08:58
  • 阅读:262

async函数中调用methods方法显示方法未定义

分类:nvue

async函数中调用methods方法显示方法未定义。
一直报错:TypeError: Cannot read property 'updateAll' of undefined。

<script>  
var _self;   
export default {  
    data() {  
         return {  

         }  
    },  
    created() {  
       _self = this;  
    },  
    methods: {  
        async getplayurl(){  
            await uni.request({  
                url: '..................',  
                method: 'POST',  
                data: {},  
                success: (res) => {  
                     _self.updateAll();//这里调用老是报错提示未定义        
                },  
                fail: (err)=> {  

                },  

            })  
        },  
        updateAll(){  
             .........  
             .........  
        }  
    }  
}  

</script>

新手卡半天了,求大佬解救!!!

2022-10-13 22:29 负责人:无 分享
已邀请:
BoredApe

BoredApe - 有问题就会有答案。

this.updateAll();
摩西bfjr

摩西bfjr

async getplayurl(){
var that = this;
await uni.request({
url: '..................',
method: 'POST',
data: {},
success: (res) => {
that.updateAll();//这里调用老是报错提示未定义
},
fail: (err)=> {

            },    

        })    
    },  

要回复问题请先登录注册