1
'하위 내용'범위는 Light DOM에 표시되지만 실제로 페이지에 렌더링되지 않습니다 (스크린 샷 참조).사용자 정의 요소 내의 하위 내용이 렌더링되지 않습니다.
누구나 왜 보이지 않는지 알 수 있습니까? 또한 분명히 슬롯을 뚫지도 않았 음을 알았습니다. 슬롯이 보이게하려는 시도였습니다.
<!doctype html>
<html>
<body>
<hello-world>
<span>Child content</span>
</hello-world>
<script>
var template = `
<span>Hello world</span>
<slot></slot>
`;
var MyElementProto = Object.create(HTMLElement.prototype);
// Fires when an instance of the element is created
MyElementProto.createdCallback = function() {
var shadowRoot = this.createShadowRoot();
shadowRoot.innerHTML = template;
};
document.registerElement('hello-world', { prototype: MyElementProto });
</script>
</body>
</html>
P.S. Chrome에 있음 57.0.2987.133
요소가 렌더링되었지만 보이지 않는다고 생각합니다. –