我尝试使用 dart/polymer 从一组地图中获取一些输入:
@CustomTag('attrib-form')
class AttribForm extends PolymerElement {
@observable List attrs = toObservable([]);
created() {
super.created();
}
init(attrs) {
this.attrs = attrs;
}
}
<!DOCTYPE html>
<polymer-element name="attrib-form">
<template if="{{attrs.length>0}}">
<template repeat="{{attr in attrs}}">
<div>
<div>{{attr['name']}}</div>
<input id="{{attr['name']}}" type="text" value="{{attr['value']}}">
</div>
</template>
</template>
<script type="application/dart" src="attrib_form.dart"></script>
</polymer-element>
main() {
var attrib = [
{"name": "name", "value": "a"},
{"name": "type", "value": "b"},
{"name": "width","value": "c"}];
var form = createElement('attrib-form');
var x = form.xtag;
x.init(attrib);
}
表单显示所有正确值都很好,但我无法更改输入值。我既不能添加也不能从输入字段中删除。
我究竟做错了什么?