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'){ //...... } } }
标签:code,vue,initParam,param,调用,接口,data From: https://www.cnblogs.com/lucky06y/p/17840403.html