<children> 标签在 fxml 中有用吗?它应该被删除吗?
Is <children> tag useful in fxml? Should it be removed?
IntelliJ checkstyle 表示应该删除这个标签,因为它不是必需的,而不是
<VBox>
<children>
<HBox>
...
</HBox>
<HBox>
...
</HBox>
</children>
</VBox>
你可以简单地拥有
<VBox>
<HBox>
...
</HBox>
<HBox>
...
</HBox>
</VBox>
有时这确实有助于避免代码臃肿,但我没能在这里找到关于约定的良好参考。
This link 提到标签作为 "the loader will automatically add the sub-elements of the VBox to the container's "children“集合”是可选的。但这并不能说明从代码中删除这个标签是否可以作为惯例?
此外,Scene Builder 似乎会将这些标签添加到新创建的控件中,但如果您删除它们并不介意。它不会在编辑此类修改后的文件时重新添加它们。
IntelliJ checkstyle 表示应该删除这个标签,因为它不是必需的,而不是
<VBox>
<children>
<HBox>
...
</HBox>
<HBox>
...
</HBox>
</children>
</VBox>
你可以简单地拥有
<VBox>
<HBox>
...
</HBox>
<HBox>
...
</HBox>
</VBox>
有时这确实有助于避免代码臃肿,但我没能在这里找到关于约定的良好参考。
This link 提到标签作为 "the loader will automatically add the sub-elements of the VBox to the container's "children“集合”是可选的。但这并不能说明从代码中删除这个标签是否可以作为惯例?
此外,Scene Builder 似乎会将这些标签添加到新创建的控件中,但如果您删除它们并不介意。它不会在编辑此类修改后的文件时重新添加它们。