vue调用完一个接口 全局中才调用另外N个接口

发布时间 2023-11-18 13:44:12作者: lucky06y
mounted(){ 
     // 先调用initParam接口 再调用第二个接口
     this.initParam().then((res)=>{
        this.getDataList();
     })
},
// 1. 把方法挂载到全局 methods: { async initParam(){ const {code,data,msg}
= await getParam() if(code === '0'){ this.param = data;
       // 2. 或者使用vuex dispath actions } }, async getDataList(){
var params = {param:this.param}; const {code,data,msg} = await getDataList(params) if(code === '0'){ //...... } } }