Route parameters in vue

The selected event of the table is invalid by default:

Method:
setCurrent(row) {
   this.$refs.singleTable.setCurrentRow(row);
 },
//stay
created() {
    this.initDeviceList();
    this.initLeftTable();
}Method initLeftTable Need to write $nextTick,Otherwise, it will not take effect
this.$nextTick(function(){
            // If it is not written in $nextTick, the first line will not be selected by default
this.scoreParent = this.leftTableList[0].evaluatConfigInfo ? JSON.parse(this.leftTableList[0].evaluatConfigInfo) : null;
this.setCurrent(this.leftTableList[0]);//Each time the data is updated, trigger this function.
this.$router.push({name: 'corroseIndex',query: { evaluatId: this.leftRowData.evaluatId, loopId:this.leftRowData.loopId }});
})

Route parameter transfer method

handleClick(tab, event) {
 if (tab.name === 'corroseIndex') {
   this.$router.push({name: 'corroseIndex',query: { evaluatId: this.leftRowData.evaluatId, loopId:this.leftRowData.loopId }});
 } else if (tab.name === 'runSituation') {
   this.$router.push({name: 'runSituation',query: { evaluatId: this.leftRowData.evaluatId, loopId:this.leftRowData.loopId }});
 } else if (tab.name === 'selfAbility') {
   this.$router.push({name: 'corroseManage'});
 }
},
//The third tab is introduced in the form of component, so you need to switch the route to the parent when clicking, otherwise the content of tab1 will be rendered together with the component

Get route parameters in subpage

watch: {
    '$route': {
        handler: function(){
            this.parentEvaluatId = this.$route.query.evaluatId;
            this.parentLoopId = this.$route.query.loopId;
            this.initStandardTableList();
            this.initIndexsTableList();
        }
    }
},
Monitor the route change through watch. Take the route parameter from the sub page. Remember this.$route, not this.$route
 At the same time: if you don't monitor the changes of routing parameters and re render the page, you can't re render the page even though the routing parameters change when you click the table on the left

Delete the same data in array B in array A and reassemble the array

for (let i = 0; i < tableList.length; i++) {
   tableList.index = i;
  for(let j = 0; j < this.standardMediumCode.length;j++){
    if(tableList[tableList.index].mediumCode === this.standardMediumCode[j]){
        tableList.splice(tableList.index, 1);
        i = -1;
    }
  }
  // for (let itemCode of this.standardMediumCode) {
  //   if (tableList[i].mediumCode === itemCode) {
  //     tableList.splice(i, 1);
  //   }
  // }
};

Keywords: JSON

Added by gerrydewar on Sun, 05 Apr 2020 17:01:41 +0300