gpt4 book ai didi

java - Vaadin 为什么我的 setvisible 不起作用?设计始终被展现

转载 作者:行者123 更新时间:2023-12-02 01:46:34 24 4
gpt4 key购买 nike

我正在使用 Designer 开发 Maven、Vaadin,但我无法解决为什么我的代码仍然显示“test”和“test2”,因为通过 testView2.setVisible(false) 应隐藏“test2”标签。这是所有相关代码。希望大家能够帮忙。

TestView.java

@Tag("test-view")
@HtmlImport("src/views/kunde/test-view.html")
@Route("test")
public class TestView extends PolymerTemplate<TestView.TestViewModel> {

@Id("testView2")
private TestView2 testView2;

public TestView() {
testView2.setVisible(false);
}

public interface TestViewModel extends TemplateModel {
}
}

test-view.html

<dom-module id="test-view"> <template>
<style include="shared-styles">
:host {
display: block;
}
</style>
<div>
<label>Label</label>
</div>
<test-view-2 id="testView2"></test-view-2>
</template> <script>
class TestView extends Polymer.Element {
static get is() {
return 'test-view';
}
static get properties() {
return {
// Declare your properties here.
};
}
}
customElements.define(TestView.is, TestView);
</script> </dom-module>

test-view-2.html

<dom-module id="test-view-2">
<template>
<style include="shared-styles">
:host {
display: block;
}
</style>
<div>
<label>test2</label>
</div>
</template>
<script>
class TestView2 extends Polymer.Element {
static get is() {
return 'test-view-2';
}
static get properties() {
return {
// Declare your properties here.
};
}
}
customElements.define(TestView2.is, TestView2);
</script>
</dom-module>

最佳答案

原因很可能是因为 Flow 在使用 setVisible(false) 时使用了 hidden HTML 属性。但因为 Designer 默认添加了 :host { display: block; } 到设计,以及 https://meowni.ca/hidden.is.a.lie.html ,设计将不遵守 hidden 属性。

您可以通过手动将以下样式添加到您的设计中来解决此问题:

:host([hidden]) {
display: none !important;
}

关于java - Vaadin 为什么我的 setvisible 不起作用?设计始终被展现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53622363/

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