|
@@ -54,6 +54,7 @@ const curKey = defineModel('modelValue', {
|
|
|
const menuData = ref(define_props.datas)
|
|
|
watch(() => define_props.datas, (data) => {
|
|
|
menuData.value = data
|
|
|
+ getItemLabel()
|
|
|
}, { deep: true })
|
|
|
|
|
|
//监听数据
|
|
@@ -83,13 +84,12 @@ const setPropsa = (obj) => {
|
|
|
|
|
|
//获取名称
|
|
|
const getItemLabel = () => {
|
|
|
- if (!curKey.value) return
|
|
|
- const { key, label } = propsa.value
|
|
|
- const data = menuData.value
|
|
|
+ const { key, label } = propsa.value, data = menuData.value
|
|
|
+ if (!curKey.value || data.length <= 0) return
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
- if (data[i][key].toString() === curKey.value.toString()) {
|
|
|
- labels.value = data[i][label]
|
|
|
- }
|
|
|
+ const name = data[i][key].toString()
|
|
|
+ const cur = curKey.value.toString()
|
|
|
+ if (name === cur) labels.value = data[i][label]
|
|
|
}
|
|
|
}
|
|
|
|