问题
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