mali-applet-ui 0.1.19 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -60,6 +60,12 @@ export default {
60
60
  }
61
61
  },
62
62
  watch: {
63
+ title () {
64
+ this.updateProp('title')
65
+ },
66
+ field () {
67
+ this.updateProp('field')
68
+ },
63
69
  itemValue () {
64
70
  if (this.form) {
65
71
  this.form.validateField(this.field)
@@ -146,6 +152,14 @@ export default {
146
152
  }
147
153
  },
148
154
  methods: {
155
+ updateProp (prop) {
156
+ if (this.form) {
157
+ const item = this.form.itemList.find(item => item.mId === this.mId)
158
+ if (item) {
159
+ item[prop] = this[prop]
160
+ }
161
+ }
162
+ },
149
163
  matchComponent (name) {
150
164
  return this.renderOpts.name === name
151
165
  },
@@ -5,6 +5,8 @@
5
5
  </template>
6
6
 
7
7
  <script>
8
+ import XEUtils from 'xe-utils'
9
+
8
10
  export default {
9
11
  name: 'MlTabPane',
10
12
  options: {
@@ -12,6 +14,7 @@ export default {
12
14
  },
13
15
  props: {
14
16
  name: [String, Number],
17
+ title: String,
15
18
  className: String
16
19
  },
17
20
  inject: {
@@ -20,7 +23,44 @@ export default {
20
23
  default: null
21
24
  }
22
25
  },
26
+ data () {
27
+ return {
28
+ mId: XEUtils.uniqueId('mlTabPane')
29
+ }
30
+ },
31
+ watch: {
32
+ name () {
33
+ this.updateProp('name')
34
+ },
35
+ title () {
36
+ this.updateProp('title')
37
+ }
38
+ },
39
+ mounted () {
40
+ this.$nextTick(() => {
41
+ if (this.tabs) {
42
+ this.tabs.tabList.push({
43
+ mId: this.mId,
44
+ name: this.name,
45
+ title: this.title
46
+ })
47
+ }
48
+ })
49
+ },
50
+ beforeDestroy () {
51
+ if (this.tabs) {
52
+ XEUtils.remove(this.tabs.tabList, item => item.mId === this.mId)
53
+ }
54
+ },
23
55
  computed: {
56
+ updateProp (prop) {
57
+ if (this.tabs) {
58
+ const item = this.tabs.tabList.find(item => item.mId === this.mId)
59
+ if (item) {
60
+ item[prop] = this[prop]
61
+ }
62
+ }
63
+ },
24
64
  selectTab () {
25
65
  return this.tabs ? this.tabs.value : null
26
66
  }
@@ -3,8 +3,8 @@
3
3
  <view class="ml-tabs-header">
4
4
  <scroll-view scroll-x>
5
5
  <view class="ml-tabs-navs" :class="[itemAlign ? `is-${itemAlign}` : '']">
6
- <view class="ml-tabs-nav-item" v-for="(item, index) in options" :key="index" :class="{'is-active': value === item.value}" :style="itemStyles" @tap="changeEvent(item)">
7
- <view class="ml-tabs-nav-title">{{ item.label }}</view>
6
+ <view class="ml-tabs-nav-item" v-for="(item, index) in tabList" :key="index" :class="{'is-active': value === item.name}" :style="itemStyles" @tap="changeEvent(item)">
7
+ <view class="ml-tabs-nav-title">{{ item.title }}</view>
8
8
  </view>
9
9
  </view>
10
10
  </scroll-view>
@@ -22,7 +22,6 @@ export default {
22
22
  name: 'MlTabs',
23
23
  props: {
24
24
  value: [String, Number],
25
- options: Array,
26
25
  className: String,
27
26
  itemAlign: String,
28
27
  itemWidth: String
@@ -33,7 +32,9 @@ export default {
33
32
  }
34
33
  },
35
34
  data () {
36
- return {}
35
+ return {
36
+ tabList: []
37
+ }
37
38
  },
38
39
  computed: {
39
40
  itemStyles () {
@@ -42,7 +43,7 @@ export default {
42
43
  },
43
44
  methods: {
44
45
  changeEvent (item) {
45
- const value = item.value
46
+ const value = item.name
46
47
  this.$emit('input', value)
47
48
  this.$emit('change', { value })
48
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "description": "码里云小程序组件库",
5
5
  "files": [
6
6
  "components",