import { NCollapse, NCollapseItem } from 'naive-ui'; import { computed, defineComponent, ref, watch } from 'vue'; import CardType from '/src/components/card-type'; import styles from './index.module.less'; export default defineComponent({ name: 'source-list', props: { knowledgePointList: { type: Array, default: () => [] }, activeItem: { type: Object, default: () => ({}) }, /** 当前播放的是第几个知识点组 */ courseActiveIndex: { type: Number, default: 0 } }, emits: ['confirm'], setup(props, { emit }) { const parentIndex = ref(props.courseActiveIndex); watch( () => props.courseActiveIndex, () => { parentIndex.value = props.courseActiveIndex; } ); const childIndex = computed(() => { let index = 0; props.knowledgePointList.forEach((item: any) => { item.list.forEach((child: any, j: number) => { if (child.id === props.activeItem.id) { index = j; } }); }); return index; }); return () => (
{props.knowledgePointList.map((item: any, index: number) => (
{ if (parentIndex.value === index) { parentIndex.value = -1; } else { parentIndex.value = index; } }}>

{item.title}

{parentIndex.value === index && item.list && item.list.map((child: any, j: number) => (
{ emit('confirm', child); }} />
))}
))}
); } });