Comments (4)
我的建议是你需要显式的声明,及即使用不着他的表单功能。如果这些字段特别多,你更应该这样做。
<Form.Item name='xx' style={{width:0, height:0}}/>
from hooks.
@raotaohub 有时候有些控件希望对应多个字段,比如range-picker 组件的值是数组但是往往后端接收的是两个字段, 我是封装 接受startkey 和endKey, 然后 给formInstance上 form.setfieldValue(startKey,xxx)这样方便也不用显式声明控件
from hooks.
@raotaohub 有时候有些控件希望对应多个字段,比如range-picker 组件的值是数组但是往往后端接收的是两个字段, 我是封装 接受startkey 和endKey, 然后 给formInstance上 form.setfieldValue(startKey,xxx)这样方便也不用显式声明控件
实际业务中这个问题确实很常见,我的做法是提交前写一个转换函数。 pro components 的高级Form组件其实就有 transform 和cover 的回调用来在提交时转换数据格式。只能说业务千变万化,组件只能尽可能提供灵活的抽象,但是没办法涵盖全部场景。。毕竟很多细节的实现没有标准化
from hooks.
@raotaohub 有时候有些控件希望对应多个字段,比如range-picker 组件的值是数组但是往往后端接收的是两个字段, 我是封装 接受startkey 和endKey, 然后 给formInstance上 form.setfieldValue(startKey,xxx)这样方便也不用显式声明控件
<ProForm.Item
hidden
name="startTime"
transform={(value, namePath, allVals) => {
return allVals
}}
convertValue={(value) => {
return value
}}
/>
最近发现 hidden 这个属性可以自动隐藏一个表单组件,而不需要额外的样式代码来手动隐藏,然后你在内部 transform convertValue去处理值,这样也是不错的
from hooks.
Related Issues (20)
- [Security] 后面是否考虑替换存在安全问题的intersection-observer依赖? HOT 1
- 请问createEffectWithTarget这个函数的设计考量是什么? HOT 3
- useLongPress 配置了 moveThreshold:{y: 10}, 在safari里有问题,safari不支持touchEvent HOT 3
- useEventEmitter emit() 方法是否支持返回一个 promise? HOT 2
- useFullscreen 使用在全屏模式下 top-layer 是否合理? HOT 1
- useRequest 新增滚动到视窗后自动请求的插件 HOT 3
- useVirtualList是否可以和useInfiniteScroll是否可以一起用? HOT 2
- Maximum update depth exceeded. HOT 1
- webpack 配置babel对node_modules下的ahooks进行编译,会有很多/* unused harmony default export */ HOT 2
- useInterval,在页面最小化,或者切换到其他页面的时候,如何防止定时器暂停啊。 HOT 1
- [RFC] useMouseInElement HOT 1
- useUrlState 设置ts类型识别不到 HOT 5
- [RFC] useTheme
- useResponsive默认的响应式配置有错误 HOT 1
- 多次调用useRequest时,慢返回的请求会覆盖快返回的请求,如何解决? HOT 3
- [RFC] useTimer
- UseRequest [Strict Mode] the first request could not be completed
- useControllableValue 的第一个参数,假如是null会直接报错
- usegetState的get函数返回值,不是我所预期的,在set函数执行后,应该在同步代码中得到最新的state变种(方便后面以最新state做判断等),可以用ref做,
- [FEATURE]CDN地址
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hooks.