Vue3中RevoGrid使用Select列类型报错:o2.sourceLookup[i2]未定义
解决RevoGrid Select列报错
TypeError: o2.sourceLookup[i2] is undefined 这个错误的核心原因是行数据中package字段的值未匹配到Select列配置的source选项,或者source格式不符合插件要求,导致插件构建的映射表(sourceLookup)找不到对应项,进而渲染失败。
修复步骤:
校验
source配置格式
确保columnsSummary中package列的source是包含labelKey和valueKey指定字段的数组,且数组项的valueKey值与行数据的package值完全一致(包括大小写、空格)。
示例配置:columnsSummary: [ { prop: 'package', name: '包', type: 'select', labelKey: 'label', // 对应source中的显示字段 valueKey: 'value', // 对应source中的值字段 source: [ { label: '包1', value: 'package 1' }, // 这里的value必须和行数据的package值完全匹配 { label: '包2', value: 'package 2' } ] } ]匹配行数据与source值
确认rowsSummary中的package字段值(如"package 1")在source的valueKey字段中存在,不能有拼写、大小写或空格差异。检查插件实例与组件绑定
确保插件实例创建正确,且v-grid组件的:column-types属性正确传递了插件对象:// Vue3 Options API 示例 data() { return { summaryGridSelectPlugin: { 'select': new SelectTypePlugin() }, // ...其他配置 } }组件绑定无拼写错误:
<v-grid :source="rowsSummary" :columns="columnsSummary" :column-types="summaryGridSelectPlugin" <!-- 其他属性 --> />
完整示例代码
<template> <v-grid readonly="false" theme="compact" :source="rowsSummary" :columns="columnsSummary" id="summary-grid" :column-types="summaryGridSelectPlugin" /> </template> <script> import SelectTypePlugin from "@revolist/revogrid-column-select"; export default { data() { return { summaryGridSelectPlugin: { 'select': new SelectTypePlugin() }, columnsSummary: [ { prop: 'package', name: '包', type: 'select', labelKey: 'label', valueKey: 'value', source: [ { label: '包1', value: 'package 1' }, { label: '包2', value: 'package 2' } ] } ], rowsSummary: [ { package: 'package 1' } ] } } } </script>
内容的提问来源于stack exchange,提问作者user2809176
相关产品推荐
相关产品推荐

