Breaking on exception: created called outside of custom element creation.
当我尝试执行以下操作时,我得到此异常,只需创建一个扩展HtmlElement
的类import 'dart:html';
void main() {
querySelector('#list_view').children.add(new ListView.created());
}
class ListView extends HtmlElement{
ListView.created() : super.created(){
new Element.ul()..children =
[
new Element.li()..text = 'test',
new Element.li()..text = 'test'
];
}
}
我做错了什么?
答案 0 :(得分:0)
我猜你不应该在Polymer元素的构造函数中执行此操作
new Element.ul()..children =
[
new Element.li()..text = 'test',
new Element.li()..text = 'test'
];
将其移至ready()
,attached()
或其他方法。