alibaba / formily

📱🚀 🧩 Cross Device & High Performance Normal Form/Dynamic(JSON Schema) Form/Form Builder -- Support React/React Native/Vue 2/Vue 3
https://formilyjs.org/
MIT License
11.47k stars 1.49k forks source link

[Bug Report] @formily/vue无法使用ref属性 #4199

Closed ksh033 closed 2 months ago

ksh033 commented 3 months ago

Reproduction link

Edit on CodeSandbox

Steps to reproduce

Vue 控件属性指定 ref,x-component-props={ref:"xxxx"}

What is expected?

$refs有xxx控件实例出现

What is actually happening?

$refs空

Package

@formily/vue@2.3.2


是否可以在ReactiveField.ts文件支持ref属性 const componentData = { attrs: { disabled: !isVoidField(field) ? field.pattern === 'disabled' || field.pattern === 'readPretty' : undefined, readOnly: !isVoidField(field) ? field.pattern === 'readOnly' : undefined, ...originData, value: !isVoidField(field) ? field.value : undefined, }, style: originData?.style, class: originData?.class, ref: originData?.ref, on: events, } delete componentData.attrs.style delete componentData.attrs.class

yiyunwan commented 2 months ago

现在就是支持的,可以使用 函数,或带value的对象

ksh033 commented 2 months ago

@yiyunwan 怎么写呢?有没 json-schema 的例子。文档内没找到ref的资料。 ,我是用了 json-schema 的写法,schema组件的属性只能用 x-component-props={ref:"table"},这个属性的传参又是通过ReactiveField,ReactiveField又没传ref给组件。