1. 程式人生 > >vue 在.vue文件裏監聽路由

vue 在.vue文件裏監聽路由

com watch creat data user nag default port pan

監聽路由 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文件裏監聽路由