-
这种用法会提示引用错误,但是实际已经传入了
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 15 replies
-
你给个 demo 复现一下,不然我们没法帮助你。 |
Beta Was this translation helpful? Give feedback.
-
https://codesandbox.io/s/453qf 你可以使用这个作为模板来修改 |
Beta Was this translation helpful? Give feedback.
-
找到原因了,上面的 SchemaRender 是通过 createSchemaField 得到的实例,通过实例传入 scope 可以在 x-reactions: "{{asd}}" 中正确调用,但是当在如下运行中使用的时候,只能拿到 createSchemaField 创建时传入的 scope {
x-reactions: {
dependencies: ['xxx'],
fulfill: { run: '{{asd}}' }
}
} |
Beta Was this translation helpful? Give feedback.
-
可能你已经解决问题了,但还是建议你把有联动的字段封装成一个组件来使用: import { useEffect } from 'react'
import useRequest from '@ahooksjs/use-request'
import { useForm } from '@formily/react'
type MockData = {
a: number
b: boolean
c: string
}
const api = (params: any) => {}
const AsyncSelect = () => {
const form = useForm<MockData>()
const { a, b, c } = form.values
const { data, run } = useRequest(api, {
manual: true
})
useEffect(() => {
run({
a,
b,
c
})
}, [a, b, c, run])
return (
<Select>
{data.map(item => (
<Option />
))}
</Select>
)
}
export default observer(AsyncSelect) |
Beta Was this translation helpful? Give feedback.
可能你已经解决问题了,但还是建议你把有联动的字段封装成一个组件来使用: