weixin_58412143 2022-12-28 13:37 采纳率: 92.1%
浏览 79
已结题

Vue 拖拽组件 vuedraggable报错

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

<div 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, }, }
  • 写回答

3条回答 默认 最新

  • WEBYANGxw 2022-12-28 14:30
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 1月5日
  • 已采纳回答 12月28日
  • 创建了问题 12月28日

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?