forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQRouteTab.js
More file actions
63 lines (62 loc) · 1.74 KB
/
QRouteTab.js
File metadata and controls
63 lines (62 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { RouterLinkMixin, routerLinkEvent, routerLinkEventName } from '../../utils/router-link'
import TabMixin from './tab-mixin'
export default {
name: 'QRouteTab',
mixins: [TabMixin, RouterLinkMixin],
inject: {
selectTabRouter: {}
},
watch: {
$route () {
this.checkIfSelected()
}
},
methods: {
select () {
this.$emit('click', this.name)
if (!this.disable) {
this.$el.dispatchEvent(routerLinkEvent)
this.selectTabRouter({ value: this.name, selected: true })
}
},
checkIfSelected () {
this.$nextTick(() => {
if (this.$el.classList.contains('q-router-link-exact-active')) {
this.selectTabRouter({ value: this.name, selectable: true, exact: true })
}
else if (this.$el.classList.contains('q-router-link-active')) {
const path = this.$router.resolve(this.to, undefined, this.append)
this.selectTabRouter({ value: this.name, selectable: true, priority: path.href.length })
}
else if (this.active) {
this.selectTabRouter({ value: null })
}
})
}
},
created () {
this.checkIfSelected()
},
render (h) {
return h('router-link', {
props: {
tag: 'div',
to: this.to,
exact: this.exact,
append: this.append,
replace: this.replace,
event: routerLinkEventName,
activeClass: 'q-router-link-active',
exactActiveClass: 'q-router-link-exact-active'
},
nativeOn: {
click: this.select
},
staticClass: 'q-tab column flex-center relative-position',
'class': this.classes,
directives: __THEME__ === 'mat'
? [{ name: 'ripple' }]
: null
}, this.__getTabContent(h))
}
}