【问题标题】:Vaadin Why is my setvisible not working? Design is always shownVaadin 为什么我的 setvisible 不起作用?始终显示设计
【发布时间】:2018-12-04 22:24:08
【问题描述】:

我正在使用 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>

【问题讨论】:

    标签: java html vaadin vaadin10


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2012-02-18
      • 1970-01-01
      • 1970-01-01
      • 2019-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-17
      • 2021-07-07
      相关资源
      最近更新 更多