Dart是否可以绑定到id属性? [英] Can Dart bind to id attribute?

查看:143
本文介绍了Dart是否可以绑定到id属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从 List 生成一个单选按钮列表,并链接< label for =xx> $ $ 标签。

I need to generate a list of radio button inputs from a List, and to link the <label for="xx"> tag to the <input>, each needs its own id.

看起来Dart不能绑定到id属性:

But it seems Dart cannot bind to an id attribute:

<div id="{{s}}">
  <p id="text">{{s}}</p> <!-- Works as expected -->
</div>

上述结果导致错误:


错误:第40行pos 22:非法使用类名DivElementautogenerated_html.DivElement __ {{s}};

Error: line 40 pos 22: illegal use of class name 'DivElement' autogenerated_html.DivElement __{{s}};

所以我的问题是:Dart是否可以绑定到id属性,如果是这样的话,

So my question is: Can Dart bind to an id attribute, and if so how?

另一个问题: web_ui生成带标签的单选按钮列表?

And an alternative question: Is there another way to use web_ui generate a list of radio button inputs with labels?

推荐答案

如示例所示,web ui编译器使用ID非常特殊方式。编译器假定它们是字符串常量,并且使用它们来生成字段和局部变量名,并查询生成的代码中的元素。

As your example shows, the web ui compiler uses IDs in a very special way. The compiler assumes they are string constants, and uses them to generate fields and local variable names and also to query for the element in the generated code.

我会说是一个错误/功能请求,应该在web_ui中以某种方式解决。您可以在此处了解有关此问题的进度: https://github.com/dart- lang / web-ui / issues / 284

I'd say this is a bug/feature request that should be addressed somehow in web_ui. You can follow progress on this issue here: https://github.com/dart-lang/web-ui/issues/284

这篇关于Dart是否可以绑定到id属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆