File tree Expand file tree Collapse file tree 6 files changed +140
-127
lines changed
Expand file tree Collapse file tree 6 files changed +140
-127
lines changed Original file line number Diff line number Diff line change 1+ import { RouterLinkMixin , routerLinkEvent , routerLinkEventName } from '../../utils/router-link'
2+ import TabMixin from './tab-mixin'
3+
4+ export default {
5+ name : 'q-route-tab' ,
6+ mixins : [ TabMixin , RouterLinkMixin ] ,
7+ watch : {
8+ $route ( ) {
9+ this . checkIfSelected ( )
10+ }
11+ } ,
12+ methods : {
13+ select ( ) {
14+ this . $emit ( 'click' , this . name )
15+ if ( ! this . disable ) {
16+ this . $el . dispatchEvent ( routerLinkEvent )
17+ this . selectTab ( this . name )
18+ }
19+ } ,
20+ checkIfSelected ( ) {
21+ this . $nextTick ( ( ) => {
22+ if ( this . $el . classList . contains ( 'router-link-active' ) || this . $el . classList . contains ( 'router-link-exact-active' ) ) {
23+ this . selectTab ( this . name )
24+ }
25+ } )
26+ }
27+ } ,
28+ created ( ) {
29+ this . checkIfSelected ( )
30+ } ,
31+ render ( h ) {
32+ return h ( 'router-link' , {
33+ props : {
34+ tag : 'div' ,
35+ to : this . to ,
36+ replace : this . replace ,
37+ append : this . append ,
38+ event : routerLinkEventName
39+ } ,
40+ nativeOn : {
41+ click : this . select
42+ } ,
43+ staticClass : 'q-tab column flex-center relative-position' ,
44+ 'class' : this . classes ,
45+ directives : [ {
46+ name : 'ripple' ,
47+ modifiers : {
48+ mat : true
49+ }
50+ } ]
51+ } , this . __getTabContent ( h ) )
52+ }
53+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import TabMixin from './tab-mixin'
2+
3+ export default {
4+ name : 'q-tab' ,
5+ mixins : [ TabMixin ] ,
6+ props : {
7+ default : Boolean
8+ } ,
9+ methods : {
10+ select ( ) {
11+ this . $emit ( 'click' , this . name )
12+ if ( ! this . disable ) {
13+ this . selectTab ( this . name )
14+ }
15+ }
16+ } ,
17+ mounted ( ) {
18+ if ( this . default && ! this . disable ) {
19+ this . select ( )
20+ }
21+ } ,
22+ render ( h ) {
23+ return h ( 'div' , {
24+ staticClass : 'q-tab column flex-center relative-position' ,
25+ 'class' : this . classes ,
26+ on : {
27+ click : this . select
28+ } ,
29+ directives : [ {
30+ name : 'ripple' ,
31+ modifiers : {
32+ mat : true
33+ }
34+ } ]
35+ } , this . __getTabContent ( h ) )
36+ }
37+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- import QRouteTab from './QRouteTab.vue '
2- import QTab from './QTab.vue '
1+ import QRouteTab from './QRouteTab'
2+ import QTab from './QTab'
33import QTabPane from './QTabPane'
44import QTabs from './QTabs.vue'
55
Original file line number Diff line number Diff line change 11import uid from '../../utils/uid'
2+ import { QIcon } from '../icon'
3+ import { QChip } from '../chip'
4+ import Ripple from '../../directives/ripple'
25
36export default {
7+ directives : {
8+ Ripple
9+ } ,
410 props : {
511 label : String ,
612 icon : String ,
@@ -54,5 +60,47 @@ export default {
5460 return 'display: none;'
5561 }
5662 }
63+ } ,
64+ methods : {
65+ __getTabContent ( h ) {
66+ const child = [ ]
67+
68+ this . icon && child . push ( h ( QIcon , {
69+ staticClass : 'q-tab-icon' ,
70+ props : {
71+ name : this . icon
72+ }
73+ } ) )
74+
75+ this . label && child . push ( h ( 'span' , {
76+ staticClass : 'q-tab-label' ,
77+ domProps : {
78+ innerHTML : this . label
79+ }
80+ } ) )
81+
82+ if ( this . count ) {
83+ child . push ( h ( QChip , {
84+ props : {
85+ floating : true
86+ }
87+ } , [ this . count ] ) )
88+ }
89+ else if ( this . alert ) {
90+ child . push ( h ( 'div' , {
91+ staticClass : 'q-dot'
92+ } ) )
93+ }
94+
95+ child . push ( this . $slots . default )
96+ if ( this . $q . theme !== 'ios' ) {
97+ child . push ( h ( 'div' , {
98+ staticClass : 'q-tabs-bar' ,
99+ style : this . barStyle
100+ } ) )
101+ }
102+
103+ return child
104+ }
57105 }
58106}
You can’t perform that action at this time.
0 commit comments