Vue 监听路由变化

与method同级的:
 
    watch: {//监听路由变化
        $route(to,from){
           if(!(this.$route.params && this.$route.params.id)) {
              this.courseInfo = {}  //清空
           }
        }
    },
原文地址:https://www.cnblogs.com/zjazn/p/14441376.html