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