有个需求是在vue 文件 main.js里面 请求接口 返回的值在其他页面上用
import { getOnlinekey } from "./api/common.js";
Vue.prototype.$GetOnlinekey=(callback)=>{
getOnlinekey().then(res=>{
let {code,result}=res.data
console.log(result,"getOnlinekey")
Vue.prototype.$KEY = {
PROCESS_ID:result.design_ID, //租赁流程的流程ID
CUSTOMER_CODE:result.sol_CUSTOMER ,//经销商表的Online表明
SOL_HELP_CENTER:result.sol_HELP_CENTER //帮助中心表 表明
}
})
if(callback){
callback()
}
}
Vue.prototype.$GetOnlinekey()
这里传了个callback ()函数
在其他页面用的时候
this.$GetOnlinekey(()=>{
this.$Nav.go('/pages/form/form', {
'processId': this.$KEY.PROCESS_ID,
title: '项目申请'
})
})
或者加个判断
if(this.$KEY.PROCESS_ID){
this.$Nav.go('/pages/form/form', {
'processId': this.$KEY.PROCESS_ID,
title: '项目申请'
})
}
还有一种情