# Tab Rules
page tab rules define different routes ways to open tabs by routing.
By configuring the routing of meta.key
properties, you can customize the tab for a particular route.
# Default Rule
By default, pages from the same route opens the same tab.
# Built-in Rules
# path
- Rule:
route => route.path
- Note: Routes with the same
route.params
share tabs. - Demo
Example:
const route = {
path: '/my-page/:id',
component: MyPage,
meta: {
title: 'Page',
key: 'path'
}
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
According to the tab rules in the example:
/my-page/1
and/my-page/2
have differentparams
, will open in separate tab./my-page/1
、/my-page/1?a=1
and/my-page/1?b=2
have the sameparams
, will open the same tab.
# fullPath
- Rule:
route => route.fullPath.replace(route.hash, '')
- Note: Routes with the same
route.params
androute.query
share tabs. - Demo
Example:
const route = {
path: '/my-page/:id',
component: MyPage,
meta: {
title: 'Page',
key: 'fullPath'
}
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
According to the tab rules in the example:
/my-page/1
and/my-page/2
have differentparams
, will open in separate tab./my-page/1
、/my-page/1?a=1
and/my-page/1?b=2
have the differentquery
, will open in separate tab.
# Custom Rule
In addition to using built-in rules, you can also customize your own rules with functions.
Example:
const route = {
path: '/my-page/:catalog/:type',
component: MyPage,
meta: {
title: 'Custom rule',
key(route) {
return `/my-page/${route.params.catalog}`
}
}
}
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
According to the tab rules in the example:
/my-page/a/1
amd/my-page/a/2
, have the sameparams.catalog
, will open the same tab./my-page/a/1
and/my-page/b/1
, have differentparams.catalog
, will open in separate tab.