我在显示/隐藏类似于此问题的组件时遇到问题:
我的布局如下:
let config: Config = {
settings: {
showCloseIcon: false,
showPopoutIcon: false
},
content: [
{
type: 'column',
content: [
{
type: 'row',
height: 25,
content: [
{
title: 'A react component',
type: 'react-component',
component: 'searchContainer'
}
],
},
{
type: 'row',
height: 75,
content: [
{
title: 'A react component',
type: 'react-component',
component: 'leftContainer'
},
{
title: 'Another react component',
type: 'react-component',
component: 'rightContainer'
}
],
},
],
}],
};
我有一个 hideSearchBar 和 showSearchBar 函数,如下所示:
function hideSearchBar() {
let container: ContentItem = layout.root.contentItems[0];
container.contentItems[1].config.height = 100;
container.contentItems[1].contentItems[0].config.height = 100;
container.contentItems[1].contentItems[1].config.height = 100;
container.config.height = 0;
container.contentItems[0].element.hide();
layout.updateSize();
//layout.updateSize($(window).width(), $(window).height());
}
function showSearchBar() {
let container: ContentItem = layout.root.contentItems[0];
container.contentItems[0].element.show();
layout.updateSize();
}
showSearchBar 完美运行并正确显示网格的两行。
hideSearchBar 正确隐藏了第一行,但留下第二行不占用整个屏幕。我已经尝试在不同的地方将 config.height 设置为 100,但无法让它工作 - 屏幕底部顶行的大小有一个间隙。
非常感谢任何帮助。