You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vue3中RevoGrid使用Select列类型报错:o2.sourceLookup[i2]未定义

解决RevoGrid Select列报错TypeError: o2.sourceLookup[i2] is undefined

这个错误的核心原因是行数据中package字段的值未匹配到Select列配置的source选项,或者source格式不符合插件要求,导致插件构建的映射表(sourceLookup)找不到对应项,进而渲染失败。

修复步骤:

  1. 校验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' }
        ]
      }
    ]
    
  2. 匹配行数据与source值
    确认rowsSummary中的package字段值(如"package 1")在source的valueKey字段中存在,不能有拼写、大小写或空格差异。

  3. 检查插件实例与组件绑定
    确保插件实例创建正确,且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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 18:05:16