0
저는 Polymer를 사용 중이며 앱 라우터 설정을 시도하고 있습니다. 앱이 방문 페이지로 사용자를 안내하도록 할 수 없습니다.방문 페이지로 연결
다른 모든 부분을 개별적으로 테스트 했으므로 내 페이지가 렌더링된다는 것을 알고 있습니다.
<dom-module id="app-body">
<template>
<app-location route="{{route}}" use-hash-as-path></app-location>
<app-route route="{{route}}" pattern="/:page" data="{{data}}"></app-route>
<iron-pages id="content-pages" selected="{{data.page}}" attr-for-selected="name">
<landing-page name="landing"></landing-page>
<lobby-page name="lobby"></lobby-page>
</iron-pages>
</template>
<script>
window.addEventListener('WebComponentsReady', function() {
Polymer({
is: 'app-body',
properties: {
data: {
type: Object,
value: function() {
return {
page: '/landing'
};
notify: true
}
}
},
observers: [
'_onRoutePathChanged(route.path)'
],
_onRoutePathChanged: function(path) {
// If we do not have an initial URL, we redirect to /landing
if (!path) {
this.set('route.path', '/landing/');
}
}
});
});
</script>
</dom-module>
당신이 옳았습니다. 폴리머 요소 수명주기의 일부인 "부착 된"이벤트를 사용해야했습니다. 이 이벤트는 "요소가 문서에 첨부 된 후"발생합니다. 문제에 대해 알려 주셨으므로 답변을 드리고 싶지만 많은 게시물은 관련이 없습니다. 내가 한 말을 분명히하기 위해 뭔가를 할 수 있다면 해답을 줄거야. –
나는 당신이 말한 것을 이해하고 모든 관련 물건을 제거했으면 좋겠습니다. – akc42