foo.html을 :중첩 된 폴리머 구성 요소 내용 문제
<link rel="import" href="bar.html">
<dom-module id="p-foo">
<template>
<p-bar>
<content select=".myContent"></content>
</p-bar>
</template>
<script>
Polymer({
is: 'p-foo',
})
</script>
</dom-module>
bar.html에는 :
<dom-module id="p-bar">
<template>
bar open
<content select=".myContent"></content>
bar closed
</template>
<script>
Polymer({
is: 'p-bar',
})
</script>
</dom-module>
demo.html :
<!DOCTYPE html>
<html>
<head>
...
<link rel="import" href="foo.html">
</head>
<body>
<p-foo><div class="myContent"><strong>hello</strong></div></p-foo>
</body>
</html>
예상 출력 :
bar open
hello
bar closed
(210)
가끔 무엇을 얻을 :
이bar open
bar closed
hello
내가 점점 오전 오류가 100 % 재현 할 수 없습니다. 페이지를 새로 고치는 시간의 비율 만 발생합니다. 또한 내용이 복잡할수록 오류 발생 확률이 높아지는 것으로 나타났습니다.
bar
구성 요소가 완전히 렌더링되기 전에 폴리머가 .myContent
을 선택하려고합니다.
위에 붙여 예에서 일부 오류가 발생했습니다. content 태그에'selector '를 사용했기 때문에 요소가'foo'와'bar' (하이픈'-'이 누락 됨)로 명명 될 수 없다는 사실을 무시하면'bar open'과'bar closed'가 출력됩니다. 한 번도 할 수 없었던 문제를 재현 할 수있는 좀 더 관련있는 예를 제공해 주시겠습니까? – a1626
@ a1626 당신은'bar open'과'bar closed'가'' –
@TomaszPluskiewicz yes에 배포되지 않기 때문에 인쇄되지 않을 것이라고 생각합니다. 현재 코드를 사용하면'content' 태그는'myContent' 클래스를 가진 객체만을 찾고 렌더링합니다. 그 외의 것은 무시합니다. – a1626