-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
title: C2D2C 辅助函数 | ||
group: | ||
title: 工具类库 | ||
order: 99 | ||
--- | ||
|
||
# generateJSXCode | ||
|
||
该方法用于将组件属性配置拼接生成 jsx 代码。 | ||
|
||
```jsx | pure | ||
import { generateJSXCode } from '@ant-design/pro-editor'; | ||
|
||
const config = { | ||
children: '默认按钮', | ||
target: '_blank', | ||
type: 'default', | ||
htmlType: 'button', | ||
danger: false, | ||
icon: '', | ||
size: 'middle', | ||
loading: true, | ||
disabled: false, | ||
ghost: false, | ||
block: false, | ||
}; | ||
|
||
const code = generateJSXCode('Button', config); | ||
``` | ||
|
||
结果为: | ||
|
||
```jsx | pure | ||
<Button | ||
target="_blank" | ||
type="default" | ||
htmlType="button" | ||
danger={false} | ||
size="middle" | ||
loading | ||
disabled={false} | ||
ghost={false} | ||
block={false} | ||
> | ||
默认按钮 | ||
</Button> | ||
``` |