fix(splash-screen): 修复H5环境下启动屏关闭后页面空白问题
问题根源分析: 1. diy-group 的 mounted() 在组件挂载时就触发了,但此时 diyData 还没有数据 2. otifyMounted() 在组件 mount 时立即关闭了 H5 的 uni.showLoading(),但页面内容还没就绪 3. 导致启动屏关闭后,首页内容还是空白的 修复方案: 1. 在 diy-group.vue 中,将 loaded 事件的触发时机改为 diyData watch 中,确保数据加载完成后再通知 2. 在 splash-state.js 中, otifyMounted() 不再立即关闭 H5 原生 loading,等待页面就绪后由 _doHide() 统一关闭 3. 在 index.js 中,onDiyGroupLoaded() 延迟 500ms 再通知页面就绪,确保内容渲染完成
This commit is contained in:
@@ -300,6 +300,7 @@ export default {
|
||||
handler() {
|
||||
this.diyGlobalData = this.diyData ? this.$util.deepClone(this.diyData) : null;
|
||||
this.processData();
|
||||
this._notifyLoaded();
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
@@ -308,8 +309,9 @@ export default {
|
||||
this.processData();
|
||||
},
|
||||
mounted() {
|
||||
// 通知父组件 diy-group 内容已渲染完毕
|
||||
this.$emit('loaded');
|
||||
if (this.diyData && this.diyData.value) {
|
||||
this._notifyLoaded();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
topNavColor() {
|
||||
@@ -323,7 +325,6 @@ export default {
|
||||
|
||||
return topNavColor;
|
||||
},
|
||||
// 过滤组件的渲染
|
||||
diyDataArray() {
|
||||
if (!this.processedData) {
|
||||
this.processData();
|
||||
@@ -347,6 +348,12 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
_notifyLoaded() {
|
||||
if (this._loadedTimer) clearTimeout(this._loadedTimer);
|
||||
this._loadedTimer = setTimeout(() => {
|
||||
this.$emit('loaded');
|
||||
}, 300);
|
||||
},
|
||||
processData() {
|
||||
if (!this.diyGlobalData || !this.diyGlobalData.value) {
|
||||
this.processedData = [];
|
||||
|
||||
Reference in New Issue
Block a user