Skip to content

feat(edit-table): formatter 支持返回 jsx 和 自定义组件#40

Merged
lianghx-319 merged 9 commits intoFEMessage:devfrom
evillt-works:feat/edit-table-formatter-support-jsx-and-component
Feb 21, 2020
Merged

feat(edit-table): formatter 支持返回 jsx 和 自定义组件#40
lianghx-319 merged 9 commits intoFEMessage:devfrom
evillt-works:feat/edit-table-formatter-support-jsx-and-component

Conversation

@eviIIt
Copy link

@eviIIt eviIIt commented Feb 19, 2020

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow Element's contributing guide (中文 | English | Español | Français).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer relative issues for you PR.

Why

close #38

Features

  • 支持 jsx
  • 支持返回自定义组件
  • 支持返回字符串

How

  • 解放 formatter 被限制在 P 元素内
  • 根据 formatter 返回结果, 判断且处理后, 再整合一个用于展示内容的组件

Others

node-sass 无法在 node v12.14.x 中运行, 大概说是 OSX 环境不支持, 降到 v11 就好
有反馈说 v12.12.0 还可以

@auto-add-label auto-add-label bot added the enhancement New feature or request label Feb 19, 2020
@netlify
Copy link

netlify bot commented Feb 19, 2020

Deploy preview for femessage-element ready!

Built with commit 5fbc557

https://deploy-preview-40--femessage-element.netlify.com

@netlify
Copy link

netlify bot commented Feb 19, 2020

Deploy preview for femessage-element ready!

Built with commit b844fe9

https://deploy-preview-40--femessage-element.netlify.com

@eviIIt eviIIt marked this pull request as ready for review February 19, 2020 07:02
Comment on lines 69 to 71
let Component = {
render: h => h('p', null, Content)
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

给这个默认的 content 加一个 class name 吧,方便以后满足样式

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

表格嵌套蛮深的呀, 要是有定制需求的话 JSX 或者自定义组件好啦!!!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个Content有必要传入formatter函数吗?
如果有必要,index和Content都是不常用的参数,顺序应该如何摆放

Copy link
Author

@eviIIt eviIIt Feb 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有必要呀, 恰好有场景用上了

这里应该改个名字, Content => cellValue(格数据)

参考 table-column 本身的 formatter, 最理想的顺序应该是 行数据, 格数据, index

没有调整顺序是由于避免出现破坏的更新嘛.

@eviIIt eviIIt force-pushed the feat/edit-table-formatter-support-jsx-and-component branch from d5f1787 to bdabb98 Compare February 21, 2020 05:27
@lianghx-319 lianghx-319 merged commit 6c4d068 into FEMessage:dev Feb 21, 2020
lianghx-319 pushed a commit that referenced this pull request Feb 24, 2020
* chore(deps): 更新 node-sass

node v12 竟然不能运行, 需要降级到 v11

* feat(edit-table): formatter 支持返回 jsx 和自定义显示组件

* style: lint

* feat(edit-table): 单元格数据

* docs(edit-table): 改善 edit-table formatter 文档

* refactor(edit-table): 更改为更明确的常量名

* improvement(edit-table): 更名, 调整 formatter 顺序

* docs(edit-table): 调整文档

* docs(edit-table): 使用 cellValue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(edit-table): formatter 支持返回定制的组件或 jsx

3 participants

Comments