gpt4 book ai didi

dart - 尝试获得dom-if上类

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

我正在尝试使用纸张切换按钮删除和添加模板内容。但是,即使发生切换,我也看不到模板的内容。

使用的代码如下所示:

。镖

PolymerRegister( 'test-if-form' )
class TestIfForm extends PolymerElement {
TestIfForm.created( ) : super.created( );

@Property( observer: 'togglerChanged' )
//@property
bool toggler = false;

@reflectable
void toggleNormalChangedEvent( event, [_] ) {
toggler = !toggler;

print( 'toggler $toggler' );
}

@reflectable
void togglerChanged( newValue, oldValue ) {
print( 'new value $newValue' );

if ( newValue ) {
toggler = !toggler;
}
}
}

.html
<dom-module id = "test-if-form">
<template>

<div
class = "layout horizontal center-justified"
id = "normal-changed-toggler-container">
<span class = "margin-rt-5px">Normal</span>
<paper-toggle-button
required
on-change = "toggleNormalChangedEvent"
id = "togglerBtn">Changed
</paper-toggle-button>
<div>
<hr>
</div>
</div>
<br>

<template is = "dom-if"
if = "{{toggler}}"
restamp>
<div>I am now visible</div>
</template>
</template>
</dom-module>

嵌套div元素的内容从不可见。好像没有被调用if?

谢谢你的帮助。

最佳答案

toggler = !toggler;

应该
set('toggler', !toggler);

关于dart - 尝试获得dom-if上类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34647075/

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