app-route 구성 요소를 사용할 수 있습니다. https://elements.polymer-project.org/elements/app-route
다음은 app-route에 대한 polycast입니다. https://www.youtube.com/watch?v=iAgSvlYavX0&list=PLOU2XLYxmsII5c3Mgw6fNYCzaWrsM3sMN&index=2
기본적으로 route 및 page 속성을 사용하여 활성 경로를 설정합니다. 어떤 코드가 활성화되어 있는지의 전환은 iron-selector 구성 요소를 사용하여 수행됩니다. 이 같은
뭔가 :
<app-location route="{{ route }}"></app-location>
<app-route route="{{ route }}"
pattern="/:page"
data="{{ routeData }}"
tail="{{ subroute }}"></app-route>
<iron-selector attr-for-selected="route"
selected="[[ page ]]"
role="navigation">
<a route="editor" href="/editor">Editor</a>
<a route="analyze" href="/analyze">Analyze</a>
<a route="community" href="/community">Community</a>
</iron-selector>
<iron-pages role="main"
attr-for-selected="route"
selected="[[ page ]]">
<my-editor route="editor"></my-editor>
<my-analyze route="analyze"></my-analyze>
<my-community route="community"></my-community>
</iron-pages>
<script>
Polymer({
is:'my-element',
properties: {
page: {
type: String,
notify: true,
reflectToAttribute: true,
observer: "_pageChanged"
}
},
observers: [
"_routePageChanged(routeData.page)"
],
attached: function(e) {
// Lazyload the views as soon as the AppShell has been Painted
this.importHref(
this.resolveUrl("my-editor.html"), null, null, true);
this.importHref(
this.resolveUrl("my-analyze"), null, null, true);
this.importHref(
this.resolveUrl("my-community"), null, null, true);
// If the application is reloaded, redirect to /analyze
if(this.page != "analyze"){
this.set("route.path", "/analyze");
}
},
_changeRoute: function(e) {
this.set("route.path", e.detail.requestRoute);
},
_routePageChanged: function(page) {
this.page = page || "analyze";
},
})
</script>
그래 난이 비디오를 보았다하지만 난 철 - 선택과 철 - 페이지 구성 요소가 내 샘플에서 탭 요소 – mahaSaez
에 연결하는 방법을 모른다 철분 선택기는 내비게이션 막대 옵션이고 철분 페이지는 페이지 전환 관리자이고 페이지는 경로 속성 값입니다. 아이언 - 선택기 옵션을 클릭하면 href "go/editor"로 URL에 알리고, 변수 페이지를 의 route 값으로 업데이트합니다. page는 사용 된 변수입니다 아이언 페이지에서 어떤 코드가 활성화되어야 하는지를 알기 때문에 attibute 페이지와 같은 이름을 가진 속성 라우트를보고 해당 코드를 활성화합니다. – MarioAleo