uniapp 微信小程序 onLaunch加载晚于onload问题
//main.js
// 执行完onLaunch后再加载onload
Vue.prototype.$onLaunched = new Promise(resolve => {
Vue.prototype.$isResolve = resolve
})
使用
//app.vue
onLaunch: function(options) {
//可按需放入onLaunch内执行的函数内部
this.$isResolve();
},
//pages/index.vue
async onLoad() {
// 等待onlauch执行完毕
await this.$onLaunched;
this.init();
},