gpt4 book ai didi

apache-flex - 设置显式宽度后将 flex 标签宽度重置为 "auto"?

转载 作者:行者123 更新时间:2023-12-04 17:42:05 29 4
gpt4 key购买 nike

一旦我设置了 widthpercentWidth flex 标签上的属性,有没有办法将宽度重置为其默认值(即文本加内边距的宽度)?

我使用标签作为渲染器。在某些情况下,我希望它自动调整文本大小,而在其他情况下,我希望它是其容器的百分比宽度。显然,我可以使用两个单独的标签,一个用于上述每种情况,但我很好奇是否可以将标签重置为其默认行为。

最佳答案

label.width = NaN;
//not sure if the following lines are required
label.invalidateSize();
label.width = label.measuredWidth;

来自 flex livedocs

When you set a specific height and width of a component, Flex does not call the measure() method, even if you explicitly call the invalidateSize() method. That is, Flex only calls the measure() method if the explicitWidth property or the explicitHeight property of the component is NaN.

关于apache-flex - 设置显式宽度后将 flex 标签宽度重置为 "auto"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1554851/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com