diff --git a/README.md b/README.md index 6282d81..3388e83 100644 --- a/README.md +++ b/README.md @@ -48,3 +48,5 @@ FineUI 100个问题题,带你走进FineUI的世界 - [25、为什么不推荐使用同步的watch]() - [26、处理树结构的常用算法]() - [27、组件生命周期与Model状态控制](https://code.fineres.com/projects/BUSSINESS/repos/nuclear-webui/pull-requests/9193/diff/#packages/bi-webui/src/modules/conf/pack/analysis/transfer/operator/dimension/combo/combo.tsx) +- [28、几个常用的布局场景]() +- [29、BI.Layers.create参数详解原理]() diff --git a/images/26.png b/images/26.png new file mode 100644 index 0000000..855bf89 Binary files /dev/null and b/images/26.png differ diff --git a/images/27.png b/images/27.png new file mode 100644 index 0000000..240320d Binary files /dev/null and b/images/27.png differ diff --git a/images/28.png b/images/28.png new file mode 100644 index 0000000..9ee79c3 Binary files /dev/null and b/images/28.png differ diff --git a/images/30.png b/images/30.png new file mode 100644 index 0000000..cd028a0 Binary files /dev/null and b/images/30.png differ diff --git a/images/31.png b/images/31.png new file mode 100644 index 0000000..081ef2b Binary files /dev/null and b/images/31.png differ diff --git a/images/32.png b/images/32.png new file mode 100644 index 0000000..e93d8ab Binary files /dev/null and b/images/32.png differ diff --git a/questions/28.几个常用的布局场景.md b/questions/28.几个常用的布局场景.md new file mode 100644 index 0000000..0b1644b --- /dev/null +++ b/questions/28.几个常用的布局场景.md @@ -0,0 +1,87 @@ +# 几个常用的布局场景 + +## 1.上对齐的水平布局如何对齐? + +举一个反面例子 + +![示例1](../images/26.png) +![示例2](../images/27.png) + + +缓存配置页面,一个水平方向布局,左侧是配置项名称,右侧是具体的配置细节. 可以很明显的看出,左右两段的水平并没有对齐 + +如何通过布局来实现齐平呢 + +一般情况下,只需要让左右两侧的元素保持相同高度即可 + +```js +const widget = { + type: "bi.horizontal", + verticalAlign: "top", + columnSize: [100, ""], + items: [ + { + type: "bi.label", + height: 36, + text: "全局缓存策略", + }, { + type: "bi.vertical", + items: [ + { + type: "bi.single_select_radio_item", + height: 36, + text: "radio1", + }, { + type: "bi.single_select_radio_item", + height: 36, + text: "radio2", + }, + ], + }, + ], +}; +``` + +![示例3](../images/28.png) + +如果是文本段落需要对齐的场景,对文本段落设置相应的行高即可.对于FineUI中label组件来说即为`textHeight`属性. FineUI中toast组件的布局方式就是如此,通过控制`textHeight` +使得icon与文字对齐 + +```js +const widget = { + type: "bi.horizontal", + width: 300, + scrollx: false, + verticalAlign: "top", + columnSize: [100, "fill"], + items: [ + { + type: "bi.label", + height: 36, + text: "全局缓存策略", + }, { + type: "bi.vertical", + items: [ + { + type: "bi.label", + whiteSpace: "normal", + textHeight: 36, + text: "S2 定位是一个轻量级的表格渲染核心,所以没有 Excel/SpreadJS 那样复杂的功能和数据模型。在大数据表格组件这个场景下,其实不需要那么重的数据模型,S2 的轻量级设计是更合适的。在性能表现上,10 个Tab 切换时,切换耗时为 80ms,是老方案的 6倍。在 5 万条数据的情况下,S2 渲染和初始化只需要 1秒。是老方案的 8 倍。\n", + }, + ], + }, + ], +}; +``` + +![示例4](../images/30.png) + +## 2. 高度自适应的tab如何使用 + +## 3. 让滚动条贴附在容器边缘的技巧 + +日常业务中会出现滚动条,如果没有贴边显示的话,视觉效果会大打折扣.直接原因是一层又一层的布局嵌套,使得当前滚动的容器自身就已经脱离了页面区域. +如何在不借助`padding`的情况下,让滚动条贴附在容器边缘呢? + +![示例5](../images/31.png) +![示例6](../images/32.png)