leisure-core 0.5.39 → 0.5.41
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="
|
|
6
|
-
:label="
|
|
7
|
-
:value="
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
};
|