그래서 다른 PolymerElement에 PolymerElement를 동적으로 추가하려고했습니다. Polymer 클래스 이름 등록
Exception: Uncaught Error: type 'HtmlElement' is not a subtype of type 'MyPolyElem ' in type cast.
I 형에 액세스하려고하면
MyPolyElem newRow = new MyPolyElem();
(newRow as MyPolyElem).type = type; // -> Exception
panelBody.append(newRow);
, 그것은 newRow이는 HTMLElement하고 "유형"을하지 않는 것을 말한다. 내가 캐스팅하려고하면 HtmlElement의 하위 유형이 아니라고합니다.
@CustomTag('poly-elem')
class MyPolyElem extends PolymerElement {
@published String type = "int";
void attached() {
super.attached();
}
factory MyPolyElem() => document.createElement("poly-elem");
MyPolyElem.created() : super.created() {}
}
분명히 폴리머 요소를 만들면 해당 HtmlElement입니다. 내가 태그와 쿼리로 HTML을 작성한다면 MyPolyElem입니다. 그래서이 태그에 대한 클래스 이름을 어떻게 등록 할 수 있는지 알고 싶습니다.
'main()'이 아니라면 어디에서이 코드를 추가 했습니까? –
다른 CustomElement에서 Button에 의해 호출되는 함수에서 호출됩니다. 새로운 Element.tag (..)은 HtmlElement를 반환합니다. – Azael
사실이 경우입니다 ... HTML 파일에서 태그를 사용하지 않았으므로 HTML을 가져 오지 않았습니다 ... – Azael