vue監聽返回值

//在url插入參數  

  // let path = this.$router.history.current.path;

    //   //對象的拷貝

    //   let newQuery = {};

    //   newQuery.pid = "123456";

    //   this.$router.push({ path, query: newQuery });

 

 created() {
    console.log("路徑:", this.$route);
    this.getInsertAccessLog();
    // console.log('queryOnlyUuid:',this.queryOnlyUuid)

     if (window.history && window.history.pushState) {
    // 往歷史記錄裏面添加一條新的當前頁面的url
    history.pushState(null, null, document.URL);
    // 給 popstate 綁定一個方法 監聽頁面刷新
    window.addEventListener('popstate', this.backChange, false);//false阻止默認事件
  }
  }

destroyed(){
  window.removeEventListener('popstate', this.backChange, false);//false阻止默認事件
},

  methods: {
    backChange() {
      const that = this;
      console.log("監聽到了");
        this.$router.push({name: 'home', query: {onlyUuid:  this.queryOnlyUuid}})
}
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章