@aochuang/common 1.0.126 → 1.0.128

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.
@@ -20,8 +20,8 @@
20
20
  <el-dropdown-item
21
21
  class="ui-dropdown__item"
22
22
  v-for="(item, index) in showOptions"
23
- :key="index"
24
- :command="index"
23
+ :key="item.id || ((item.value || item.label || 'item') + '-' + index)"
24
+ :command="{ index, item }"
25
25
  :divided="item.divided || (item.props && item.props.divided)"
26
26
  :disabled="item.disabled || (item.props && item.props.disabled)"
27
27
  :class="handleRenderItemClass(item)"
@@ -29,7 +29,8 @@
29
29
  <slot name="item" :item="item">
30
30
  <ui-icon v-if="item.icon || (item.props && item.props.icon)" class="ui-dropdown__item-icon" :name="item.icon || (item.props && item.props.icon)"></ui-icon>
31
31
  <span class="ui-dropdown__item-text">
32
- <component :is="item.component"></component>
32
+ <component v-if="item.component" :is="item.component"></component>
33
+ <template v-else>{{ item.label || (item.props && item.props.label) }}</template>
33
34
  </span>
34
35
  </slot>
35
36
  </el-dropdown-item>
@@ -167,7 +168,11 @@ export default {
167
168
  return cls
168
169
  },
169
170
  handleCommand (e) {
170
- const item = this.showOptions[e]
171
+ const index = e && typeof e === 'object' ? e.index : e
172
+ const item = e && typeof e === 'object' ? e.item : this.showOptions[e]
173
+ if (!item) {
174
+ return
175
+ }
171
176
  // 兼容以前的老逻辑,如果配置了item-click就不允许执行item.click了,因为后面新的方式可以直接监听dropdown-item的时间,能带上下文数据
172
177
  if (!this.$listeners['item-click']) {
173
178
  if (item.click) {
@@ -176,7 +181,7 @@ export default {
176
181
  }
177
182
  this.$emit('input', item.value)
178
183
  this.$emit('item-click', {
179
- index: e,
184
+ index,
180
185
  item,
181
186
  itemData: this.itemData
182
187
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aochuang/common",
3
- "version": "1.0.126",
3
+ "version": "1.0.128",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "publishConfig": {