#4354·formily

[Bug Report] PreviewText.Cascader 异步获取的数据无法获取到选择的数据名称

Author: AmorDiamondCreated Feb 27, 2026Updated Feb 27, 2026
  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

通过请求获取到的数据结构如下图

Image

在组件属性里配置了 x-component-props: {fieldNames: "{{{ label: "name", value: "code"}}}", showSearch: true},编辑状态是没问题的,但是在阅读态模式下不能显示选择的数据名称

Image

看了PreviewText.Cascader源码,内部没有处理 fieldNames 配置的逻辑。但是重新自定义Cascader组件时使用mapReadPretty似乎无法传入异步获取到的数据属性,自定义代码如下:

function PreviewTextCascader(props: CascaderProps) {
  // 这里 props 里拿不到异步请求的 dataSource 或 options 数据
  console.log('PreviewTextCascader', props)
  return null
}

const CascaderComponent = connect(
  AntCascader,
  mapProps({ dataSource: 'options' }, (props) => ({ ...props })),
  mapReadPretty(PreviewTextCascader),
)

......
const SchemaField = createSchemaField({
  components: {
    Cascader: CascaderComponent,
  }
})

What is expected?

PreviewText.Cascader 内部添加处理 fieldNames 配置的逻辑

What is actually happening?

PreviewText.Cascader 内部没有处理 fieldNames 配置的逻辑

Package

@formily/[email protected] @formily/[email protected]