我有以下的 ELM 视图元素:
Html.node "test-elem"
[ Attributes.attribute "data-count" (model.count |> String.fromInt) ]
[]
test-elem是一个自定义的HTML元素:
constructor() {
super();
this.me = this;
}
connectedCallback() {
console.info(this.dataset.count);
this.div = document.createElement("div");
this.appendChild(this.div);
this.div.innerText = "" + this.dataset.count;
}
attributeChangedCallback() {
console.info(this.dataset.count);
this.div.innerText = "" + this.dataset.count;
}
如果model.count更改,自定义元素不会被重新生成。我该如何强制刷新呢? https://ellie-app.com/6SRrZjCzwfra1 经过@Robin的建议编辑,但没有成功。
static get observedAttributes() { return ['data-count']; }
- Murdock