关联组件问题

This commit is contained in:
851673013@qq.com 2022-07-04 11:24:29 +08:00
parent e849f37f1e
commit d4ecfc74a4
2 changed files with 35 additions and 13 deletions

View File

@ -33,7 +33,7 @@
></application-associated-components> ></application-associated-components>
<!-- 关联能力 --> <!-- 关联能力 -->
<application-associated-ability <application-associated-ability
:associatedComponents="associatedComponents" :associatedComponents="associatedComponentsFunction()"
id="application-associated-ability" id="application-associated-ability"
class="scrollBox" class="scrollBox"
></application-associated-ability> ></application-associated-ability>
@ -172,6 +172,15 @@
console.log('预览==============', obj) console.log('预览==============', obj)
} }
} }
const associatedComponentsFunction = () => {
if (
associatedComponents.value[0].dataList.length > 0 ||
associatedComponents.value[1].dataList.length > 0 ||
associatedComponents.value[2].dataList.length > 0
) {
return associatedComponents.value
}
}
init(id) init(id)
onBeforeUnmount(() => { onBeforeUnmount(() => {
mybus.off('flyToView') mybus.off('flyToView')

View File

@ -46,24 +46,37 @@
}, },
}) })
} }
if ( if (props.associatedComponents) {
props.associatedComponents[0].dataList.length > 0 || if (
props.associatedComponents[1].dataList.length > 0 || props.associatedComponents[0].dataList.length > 0 ||
props.associatedComponents[2].dataList.length > 0 props.associatedComponents[1].dataList.length > 0 ||
) { props.associatedComponents[2].dataList.length > 0
flag.value = true ) {
dataFrom.value = props.associatedComponents flag.value = true
console.log('dataFrom.value', dataFrom.value) dataFrom.value = props.associatedComponents
console.log('dataFrom.value', dataFrom.value)
} else {
flag.value = false
}
} else { } else {
flag.value = false flag.value = false
} }
watch( watch(
() => props.associatedComponents, () => props.associatedComponents,
(val) => { (val) => {
if (val) { if (props.associatedComponents) {
flag.value = true if (
dataFrom.value = props.associatedComponents val[0].dataList.length > 0 ||
console.log('dataFrom.value', dataFrom.value) val[1].dataList.length > 0 ||
val[2].dataList.length > 0
) {
flag.value = true
dataFrom.value = props.associatedComponents
// console.log('dataFrom.value', dataFrom.value)
} else {
flag.value = false
}
} else { } else {
flag.value = false flag.value = false
} }