alibaba / lowcode-engine

An enterprise-class low-code technology stack with scale-out design / 一套面向扩展设计的企业级低代码技术体系
https://lowcode-engine.cn
MIT License
14.65k stars 2.55k forks source link

请问如何给StyleSetter设置默认值? #739

Closed yz1311 closed 2 years ago

yz1311 commented 2 years ago

复现截图

想给StyleSetter直接设置默认值,目前碰到一些问题,用snippets的方式,直接给style赋值是可以的,但是界面里面的占位视图会消失, 查询源码得到,这里对style有做判断,如果不为空,就直接不显示占位视图,请问这样做是为什么?那我如何能给StyleSetter设置默认值,并且保留占位视图?

复现流程与链接

WX20220628-120308

 {
          "componentName": "Column",
          "library": "LYMaterials",
          "title": "Column",
          "icon": "",
          "snippets": [
            {
              "title": "Column",
              "schema": {
                "componentName": "Column",
                "title": "Column",
                "props": {
                  "style": {
                    "display": "flex",
                    "flexDirection": "column"
                  }
                }
              }
            }
          ]
        },

WX20220628-120211

这里有做判断 https://github.com/alibaba/lowcode-engine/blob/main/packages/react-simulator-renderer/src/renderer-view.tsx#L205

image

期望结果

StyleSetter设置默认值,并且保留占位视图

环境信息

LeoYuan commented 2 years ago

可以通过在设计视图里,自定义占位符实现~

class YourComponent {
  render() {
    if (this.props.leaf.isEmpty) {
      return <div>空</div>;
    }
    return 其他视图;
  }
}
github-actions[bot] commented 2 years ago

This issue is stale because it has been open 10 days with no activity. Remove stale label or comment or this will be closed in 2 days.

github-actions[bot] commented 2 years ago

This issue was closed because it has been stalled for 10 days with no activity.