提交 | 用户 | age
|
67dc7b
|
1 |
'use strict'; |
S |
2 |
Object.defineProperty(exports, '__esModule', { value: true }); |
|
3 |
var component_1 = require('../common/component'); |
|
4 |
component_1.VantComponent({ |
|
5 |
props: { |
|
6 |
info: null, |
|
7 |
name: null, |
|
8 |
icon: String, |
|
9 |
dot: Boolean, |
d34532
|
10 |
iconPrefix: { |
S |
11 |
type: String, |
|
12 |
value: 'van-icon', |
|
13 |
}, |
67dc7b
|
14 |
}, |
S |
15 |
relation: { |
|
16 |
name: 'tabbar', |
|
17 |
type: 'ancestor', |
|
18 |
current: 'tabbar-item', |
|
19 |
}, |
|
20 |
data: { |
|
21 |
active: false, |
|
22 |
}, |
|
23 |
methods: { |
|
24 |
onClick: function () { |
d34532
|
25 |
var parent = this.parent; |
S |
26 |
if (parent) { |
|
27 |
var index = parent.children.indexOf(this); |
|
28 |
var active = this.data.name || index; |
|
29 |
if (active !== this.data.active) { |
|
30 |
parent.$emit('change', active); |
|
31 |
} |
67dc7b
|
32 |
} |
S |
33 |
this.$emit('click'); |
|
34 |
}, |
|
35 |
updateFromParent: function () { |
|
36 |
var parent = this.parent; |
|
37 |
if (!parent) { |
|
38 |
return; |
|
39 |
} |
|
40 |
var index = parent.children.indexOf(this); |
|
41 |
var parentData = parent.data; |
|
42 |
var data = this.data; |
|
43 |
var active = (data.name || index) === parentData.active; |
|
44 |
var patch = {}; |
|
45 |
if (active !== data.active) { |
|
46 |
patch.active = active; |
|
47 |
} |
|
48 |
if (parentData.activeColor !== data.activeColor) { |
|
49 |
patch.activeColor = parentData.activeColor; |
|
50 |
} |
|
51 |
if (parentData.inactiveColor !== data.inactiveColor) { |
|
52 |
patch.inactiveColor = parentData.inactiveColor; |
|
53 |
} |
d34532
|
54 |
if (Object.keys(patch).length > 0) { |
S |
55 |
this.setData(patch); |
|
56 |
} |
67dc7b
|
57 |
}, |
S |
58 |
}, |
|
59 |
}); |