微信小程序 全局App.js

个人见解 如有错误 敬请提出

关于App.js与其他页面 的代码 的执行顺序

在APP.js中  定义这样一个方法

如果在App.js中做了判断  就可以抛出不同的回调

成功
if (APPTHIS .success ) {
APPTHIS . success (res )
}
失败
if (APPTHIS .fail ) {
APPTHIS . fail (res )
}

在其他的js中

//判条件 执行不同的回调
if (APP .PapeData .userInfo ) {
this .init ()
} else {
APP . success = res => {
this .init ()
}
APP . fail = res => {
this .init ()
}
}

猜你喜欢

转载自blog.csdn.net/qinlulucsdn/article/details/80373253