首页 > 代码库 > weex 页面返回事件

weex 页面返回事件

<template>
  <div @viewappear="viewappear" @viewdisappear="viewdisappear">
    <text>页面返回 </text>
  </div>
</template>
<script>
  const modal = weex.requireModule(modal)
  export default {
    data(){
        return {
            pageBack: false,
        }
    },
    methods: {
            viewdisappear(){
                let self=this;
                self.pageBack = true;
            },
            viewappear(){
                let self=this;
                if(!self.pageBack){ return; }
                self.pageBack = false;
                
                modal.toast({ message: "页面回来了", duration: 10 });
                
            },
            
    }
  }
</script>

 

 

基本实现思路是 用weex自带的 viewappear 和 viewdisappear做一个简单的判断

weex 页面返回事件