简体   繁体   English

如何从DART代码更新聚合物元素属性

[英]How to update polymer element attribute from dart code

I am trying to learn dart and polymer. 我正在尝试学习飞镖和聚合物。 Here repository that I try to learn on: 我尝试在此处学习的存储库:

https://bitbucket.org/romanoff/polymer_sample https://bitbucket.org/romanoff/polymer_sample

When I try to set attribute from dart code of one custom element to other custom element, it doesn't seem to work. 当我尝试将属性从一个自定义元素的飞镖代码设置为另一个自定义元素时,它似乎不起作用。 Here is line where I try to do this: https://bitbucket.org/romanoff/polymer_sample/src/f8314627fe8eee9f6fde58c300acf081b396f927/web/clickcounter/clickcounter.dart?at=master#cl-33 这是我尝试执行此操作的行: https : //bitbucket.org/romanoff/polymer_sample/src/f8314627fe8eee9f6fde58c300acf081b396f927/web/clickcounter/clickcounter.dart?at=master#cl-33

Have also tried following options: var timer = $['timer'].xtag; timer.textValue = 'Text value set form attached handler'; 还尝试了以下选项: var timer = $['timer'].xtag; timer.textValue = 'Text value set form attached handler'; var timer = $['timer'].xtag; timer.textValue = 'Text value set form attached handler';

var timer = $['timer']; timer.setAttribute('textValue', 'Text value set form attached handler');

There are two ways 有两种方法

$['timer'].attributes['textValue'] = 'Text value set form attached handler';

or 要么

import 'path_to_dart_file_containing_timer_component#;

...

($['timer'] as MyTimer).textValue = 'Text value set form attached handler'; 

where MyTimer is the name of the class of your timer element 其中MyTimer是您的计时器元素的类的名称
and your timer component class has a field 并且您的计时器组件类具有一个字段

@published String textValue;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM