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

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日

悬赏问题

  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测