flatiron-director / core-pages SPA with route specific js functions & default route

对着背影说爱祢 提交于 2019-12-04 05:15:57

问题


i am working with flatiron-director and core-pages. my question is how would i set a default route? also how do i call js functions on specific routes.

my code looks something like this

<template is="auto-binding">
  <flatiron-director id='page-director' route="{{route}}" 
                   autoHash on-director-route="{{routeChanged}}"></flatiron-director>

    <core-menu id="menu">
      <paper-item icon="list" label="1">
        <a href="#1"></a>
      </paper-item>
      <paper-item icon="swap-vert" label="2">
        <a href="#2"></a>
      </paper-item>
      <paper-item icon="file-download" label="3">
        <a href="#3"></a>
      </paper-item>
    </core-menu>

    <core-pages selected="{{route}}"  valueattr="page">
      <div page="1">
        //page 1
      </div>
      <div page="2">
        // page 2
      </div>
      <div page="3">
        //page 3
      </div>
    </core-pages>

</template>

回答1:


This app sets a default route and should demonstrate what you want: http://polymer-change.appspot.com/demos/spa.html.

I believe the relevant code would be:

var template = document.querySelector('template');

template.addEventListener('template-bound', function() {
  this.route = this.route || 1; // default route to "1".
});


来源:https://stackoverflow.com/questions/25454926/flatiron-director-core-pages-spa-with-route-specific-js-functions-default-ro

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!