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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
| Component({
| /**
| * 组件的属性列表
| */
| properties: {
| tabbarData: { //tabbar的数据
| type: null,
| observer: function(newVal, oldVal) {
|
| this.setData({
| list: newVal
| })
| }
| },
| active: { //选中的下标
| type: null,
| observer: function(newVal, oldVal) {
|
| if (newVal != '') {
| this.setData({
| selected: newVal
| })
| }
| }
| },
| bgcolor: { //背景颜色
| type: null,
| observer: function(newVal, oldVal) {
|
| if (newVal != '') {
| this.setData({
| bgcolor: newVal
| })
| }
| }
| },
| color: { //未选中的字体颜色
| type: null,
| observer: function(newVal, oldVal) {
|
| if (newVal != '') {
| this.setData({
| color: newVal
| })
| }
| }
| },
| selectedColor: { //选中的字体颜色
| type: null,
| observer: function(newVal, oldVal) {
|
| if (newVal != '') {
| this.setData({
| selectedColor: newVal
| })
| }
|
| }
| },
| showborder: { //选中的字体颜色
| type: null,
| observer: function (newVal, oldVal) {
|
| if (newVal != '') {
| this.setData({
| showborder: newVal
| })
| }
|
| }
| },
| bordercolor: { //分割线的颜色
| type: null,
| observer: function (newVal, oldVal) {
|
| if (newVal != '') {
| this.setData({
| bordercolor: newVal
| })
| }
|
| }
| },
| },
| /**
| * 数据赋值
| */
| data: {
| selected: 0,//选中的下标
| showborder:true,//显示分割线
| bordercolor:"#0000ff",//分割线的颜色
| bgcolor: "#ffffff",//背景颜色
| color: "#cccccc",//未选中的字体颜色
| selectedColor: "#333333",//选中的字体颜色
| list: [],//tabbar的数据列表
| },
| //项目初始化
| attached: function() {
|
| },
| methods: {
| switchTab(e) {
| var that = this;
| that.setData({
| selected: parseInt(e.currentTarget.dataset.index)
| })
|
| //回调函数
| that.triggerEvent('tapChange', parseInt(e.currentTarget.dataset.index));
| },
| }
| })
|
|