king
2019-08-14 68cbb649c933776838e937446ce9ed384916a5e8
src/views/companyProfile/index.vue
@@ -257,13 +257,16 @@
   data() {
      return {
      img_index:0,
      anchor:false,
      anchor: false
      }
   },
   mounted () {
    let url = location.href
    let hash = url.substring(url.length-9)
    this.get_anchor(hash)
  watch: { //监听路由
    $route (to, from) {
      if (to.params.hash && to.params.hash !== 'null') {
        this.anchor = true
        this.get_anchor(to.params.hash)
      }
    }
   },
   methods: {
    //根据hash值跳转不同锚点
@@ -273,16 +276,11 @@
      }
    }
  },
  destroyed () { //返回顶部
    document.body.scrollTop = 0
    document.documentElement.scrollTop = 0
  },
  watch: { //监听路由
    $route (to,from) {
      if (to.hash) {
   mounted () {
    let hash = this.$route.params.hash
    if (hash && hash !== 'null') {
        this.anchor = true
        this.get_anchor(to.hash)
      }
      this.get_anchor(hash)
    }
  }
}