leisure-core 0.5.39 → 0.5.40

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.
@@ -1,14 +1,15 @@
1
1
  <template>
2
2
  <div>
3
3
  <el-option
4
- v-for="item in options"
5
- :key="handleKv('key', item)"
6
- :label="handleKv('label', item)"
7
- :value="handleKv('value', item)"
4
+ v-for="(item, index) in options"
5
+ :key="getOptionKey(index)"
6
+ :label="getOptionLabel(item)"
7
+ :value="getOptionValue(item)"
8
8
  ></el-option>
9
9
  </div>
10
10
  </template>
11
11
  <script>
12
+ let instanceCounter = 0;
12
13
  export default {
13
14
  name: "le-select-option",
14
15
  props: {
@@ -31,19 +32,37 @@ export default {
31
32
  default: 1,
32
33
  },
33
34
  },
35
+ data() {
36
+ return {
37
+ instanceId: instanceCounter++,
38
+ };
39
+ },
34
40
  mounted() {},
35
41
  methods: {
36
- handleKv(type, item) {
37
- if (this.keyNum == 1) {
38
- if (type == "key" || type == "value") {
39
- return item[this.value];
40
- } else if (type == "label") {
41
- return item[this.label];
42
- }
43
- }
44
- if (this.keyNum == 2) {
45
- return item[this.value] + "-" + item[this.label];
46
- }
42
+ // handleKv(type, item) {
43
+ // if (this.keyNum == 1) {
44
+ // if (type == "key" || type == "value") {
45
+ // return item[this.value];
46
+ // } else if (type == "label") {
47
+ // return item[this.label];
48
+ // }
49
+ // }
50
+ // if (this.keyNum == 2) {
51
+ // return item[this.value] + "-" + item[this.label];
52
+ // }
53
+ // },
54
+
55
+ getOptionKey(index) {
56
+ // 最简单可靠的方案:使用组件实例ID + 索引
57
+ return `${this.instanceId}_${index}`;
58
+ },
59
+
60
+ getOptionLabel(item) {
61
+ return item[this.label] || "";
62
+ },
63
+
64
+ getOptionValue(item) {
65
+ return item[this.value] || "";
47
66
  },
48
67
  },
49
68
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leisure-core",
3
- "version": "0.5.39",
3
+ "version": "0.5.40",
4
4
  "description": "leisure-core是京心数据基于vue2.x开发的一套后台管理系统桌面端组件库,封装了大量实用的UI控件模板,非常方便开发者快速搭建前端应用",
5
5
  "private": false,
6
6
  "author": "北方乐逍遥(zcx7878)",