【发布时间】:2016-05-07 00:12:26
【问题描述】:
我正在尝试在 dart 中制作自定义元素。它应该只包含 2 个按钮。它从来没有真正通过施工过程......我做错了什么?
class GraphButton extends Element {
factory GraphButton() => new Element.tag('GraphButton');
ButtonElement colorBtn;
ButtonElement removeBtn;
GraphButton.created() : super.created() {
}
void setup(String buttonText) {
text = buttonText;
//initialize color btn
colorBtn
..id = 'colorBtn' + text
..text = "colorSelector"
..onClick.listen(
(var e) => querySelector('#output').text = id + 'button clicked!');
//initialize remove button
removeBtn
..id = 'removeBtn' + text
..text = 'X'
..onClick.listen(
(var e) => this.remove());
//add to DOM
this.children
..add(colorBtn)
..add(removeBtn);
}
}
【问题讨论】:
-
有什么问题?我现在没有时间仔细研究,但是这里已经有类似的问题和答案了。