Vue 拖拽组件 vuedraggable报错

报错:Cannot read property 'com' of undefined
怎么解决?我引入了,也定义了,怎么还是 undefined?

class="view-content" :style="{ backgroundColor: info.backgroundColor }" @drop="drog" @dragover="dragOver"> <Draggable v-model="ViewPC" draggable=".item"> <template v-for="(item, index) in ViewPC"> <div v-if="index > 0" :key="index" :data-index="index" :class="{ item: true, active: currentIndex === index }" @click="selectType(index)"> <template v-if="item.status && item.status === 2"> <div class="wait">{{ item.type }}div> template> <template v-else> <component :is="typeList[item.type]['com']" :data="item" /> template> <span class="span-error" @click="deleteItem($event, index)"> <i class="el-icon-delete del-css" />span> div> template> Draggable>
import Space from '@/components/ViewPC/Space' import Type from '@/components/ViewPC/Type' components: { Space, Type, }, typeList: { space: { name: "用户信息", icon: "icon-shangpinguanli", iconStyle: "spanStyle02", // com: Space, }, type: { name: "分类", icon: "el-icon-document-copy", iconStyle: "spanStyle02", // com: Type, }, }

component is 的是一个字符串,它是要你告诉它 应该显示哪个名字的组件。typeList[item.type] 是什么 打印看看。 然后看看typeList[item.type] 有没有 com 这个属性。这个属性的值 有没有引入。30行 我看你都注释了....

需要在组件的 components 选项中注册组件。您可以将组件 Space 和 Type 注册为局部组件,如下所示:

components: {
  Space,
  Type,
},