Asynchronous interface requests multiple optimized writing methods

async init() {
    
    
      // 数据字典:库区号
      await this.$http
        .get("/api/ms/api/getlist1")
        .then((res) => {
    
    
          this.stockNo = res.data.map((ele) => {
    
    
            return {
    
     value: ele.stockId, label: ele.stockName };
          });
        });

      this.$http.get("/api/ms/api/getlist2").then((res) => {
    
    
        this.tableData = res.data;

      });
    },

Use async await syntax sugar to avoid callback regions

Guess you like

Origin blog.csdn.net/qq_45989814/article/details/123142944