mpvue应用之组件数据缓存清理
作者:互联网
main.ts
Vue.mixin({ // 监听页面加载 onLoad() { this.componentShow = true; }, // 监听页面卸载 onUnload() { if (!this.$options.parent && this.$options.data) { this.componentShow = false; Object.assign(this.$data, this.$options.data()); } }, });
页面中调用:
<script lang="ts"> private componentShow: boolean = false;script><Popup v-if="componentShow" title="仓库记录" :show="recordShow" :content="buildingRecord" @cancel="popupShow('recordShow')" @confirm="recordConfirm" />
参考链接:https://zhuanlan.zhihu.com/p/50759400
标签:缓存,mpvue,componentShow,监听,组件,false,data,options,页面 来源: https://blog.51cto.com/u_14302606/2817973