首页 > 其他 > 详细

vue 在.vue文件里监听路由

时间:2019-02-14 15:38:31      阅读:280      评论:0      收藏:0      [点我收藏+]

监听路由  watch   $route

vue项目中的App.vue 文件

<template>
  <div id="app">
      <!--include=[AdminUserManage,createUser]-->
      <keep-alive >
          <router-view/>
      </keep-alive>
      <TabBer v-if="tabbarshow"/>

  </div>
</template>
<script>
import TabBer from ‘./components/public/TabBar.vue‘
export default {
    components:{
        TabBer,
    },
    data() {
        return {
        tabbarshow:false
        }
    },
     watch: {
        $route(to,from) {
            if(this.$route.path == "/Home"){
            this.tabbarshow = true
            }else if(this.$route.path ==‘/more‘||this.$route.path ==‘/More‘){
                this.tabbarshow = true
            }else{
                this.tabbarshow = false
            }
        }
     },
    created(){
        if(this.$route.path == "/Home"){
            this.tabbarshow = true
        }else if(this.$route.path ==‘/more‘||this.$route.path ==‘/More‘){
                this.tabbarshow = true
        }else{
            this.tabbarshow = false
        }
    }
}
</script>

<style>

</style>

 

vue 在.vue文件里监听路由

原文:https://www.cnblogs.com/taohuaya/p/10374841.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!