diff --git a/docs/private/formLayout.md b/docs/private/formLayout.md new file mode 100644 index 0000000..2f79d8f --- /dev/null +++ b/docs/private/formLayout.md @@ -0,0 +1,10 @@ +--- +group: + title: 对内测试 + order: 99 +title: Form布局 +order: 1 +--- + + + diff --git a/docs/private/formLayout.tsx b/docs/private/formLayout.tsx new file mode 100644 index 0000000..5518eee --- /dev/null +++ b/docs/private/formLayout.tsx @@ -0,0 +1,48 @@ +import React from 'react'; +import { Form } from 'sula'; + +export default class LayoutDemo extends React.Component { + render() { + return ( +
+ ); + } +} diff --git a/packages/sula/package.json b/packages/sula/package.json index dc8b2ac..c849051 100644 --- a/packages/sula/package.json +++ b/packages/sula/package.json @@ -1,6 +1,6 @@ { "name": "sula", - "version": "1.2.0-beta.41", + "version": "1.2.0-beta.42", "module": "./es/index.js", "main": "./es/index.js", "types": "./es/index.d.ts", diff --git a/packages/sula/src/form/utils/layoutUtil.ts b/packages/sula/src/form/utils/layoutUtil.ts index 65a54c6..a2bda72 100644 --- a/packages/sula/src/form/utils/layoutUtil.ts +++ b/packages/sula/src/form/utils/layoutUtil.ts @@ -10,16 +10,13 @@ export function getItemLayout( const finalSpan = getItemSpan(itemLayout, matchedPonint); - let finalOffset = offset; - let finalGutter = gutter; + let finalOffset = isNumber(offset) ? offset : 0; + let finalGutter = isNumber(gutter) ? gutter : 24; let finalWrapperCol; let finalLabelCol; if (layout === 'vertical' || layout === 'horizontal') { - finalOffset = finalOffset || 0; - finalGutter = finalGutter || 24; - // 只有水平布局需要设置 wrapperCol 和 labelCol if (layout === 'horizontal') { finalLabelCol = labelCol || { span: 8 }; @@ -35,7 +32,7 @@ export function getItemLayout( labelCol: finalLabelCol, span: finalSpan, offset: finalOffset, - gutter: finalGutter || 0, + gutter: finalGutter, }; }