带有路由特定js功能的熨斗导演/核心页面SPA&默认路线 [英] flatiron-director / core-pages SPA with route specific js functions & default route
本文介绍了带有路由特定js功能的熨斗导演/核心页面SPA&默认路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在与熨斗导演和核心页面打交道.我的问题是如何设置默认路由?还有如何在特定路由上调用js函数.
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.
我的代码看起来像这样
<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>
推荐答案
This app sets a default route and should demonstrate what you want: http://polymer-change.appspot.com/demos/spa.html.
我相信相关代码将是:
var template = document.querySelector('template');
template.addEventListener('template-bound', function() {
this.route = this.route || 1; // default route to "1".
});
这篇关于带有路由特定js功能的熨斗导演/核心页面SPA&默认路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文