Vue sets route jump parameters, and receives parameters

When I was working on a Vue project recently, I encountered a routing jump problem: the home page wants to jump to the tab item specified on the project page, and it always jumps to the default item at the beginning. The workaround is as follows:

The routing jump parameters are set at the jump link, as follows:

<router-link  :to="{path:'/project',query:{tab:0}}" >项目页</router-link>

Then receive the parameters passed by the query on the project page, and write a method in methods:

cc:function(){

var tabId = this.$route.query.tab;

this.index = tabId; //index is the parameter to control switching
},

Then put this method into mounted(){} to execute

Note: The value of tab is the parameter you wrote in the tab. For example, if you set a variable index, index=0 is to display the content of the first tab.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325020438&siteId=291194637