直观查看vue中的async await用法

methods: {
//移步请求
     async generateData (){
//等待请求结果
       let _result = await this.getProductslist() 
       console.log(_result)//findAppMenu 返回信息
    },
    getProductslist(){
      return new Promise((resolve,reject)=>{
        this.findAppMenu(resolve)
      })
    },
    findAppMenu(resolve){
      let _this = this;
        let param = {};
        _this.$store
        .dispatch("FINDAPPMENU", { param })
        .then(res => {
          resolve(res)
           //返回结果数据处理
        })
        .catch(res => {
          console.error(res);
        });
    },
}

 

你可能感兴趣的:(vue)