在我的web应用程序中,我有一个路由问题,问题是我的index.html中有一个不同的部分,在其中一个部分我有一个纸按钮元素,所以当用户点击这个按钮时,我想路由到另一个部分,下面是一些代码,这样您就可以更好地理解:
Index.html
<iron-pages attr-for-selected="data-route" selected="{{route}}" id="main_pages">
<section data-route="home">
<my-register></my-register>
<div class="div-vertical-flex">
<my-generalcard id="generalcard_1"></my-generalcard>
<my-generalcard id="generalcard_2"></my-generalcard>
<my-generalcard id="generalcard_3"></my-generalcard>
</div>
</section>
<section data-route="blog">
<my-blog></my-blog>
</section>
<section data-route="pricing">
<my-pricing-start></my-pricing-start>
<my-pricingaccount></my-pricingaccount>
</section>
<section data-route="contactus">
<my-contact></my-contact>
</section>
<section data-route="product">
<my-product></my-product>
</section>
<section data-route="login">
<my-login></my-login>
</section>
<section data-route="register">
<my-registerpage></my-registerpage>
</section>
</iron-pages>
包含带有按钮的元素的部分是:home
,元素是:my-register
。
routing.html
page('/register/:email', function(data) {
app.route = 'register';
app.params = data.params;
});
上面是我声明的routing.html.Where中的函数,我将接收url /register/:email
,并将重定向到注册部分。
my-register.html
<paper-button raised id="bt_register" on-tap="handleRegisterTap" class="paper-button-fullsize">
Continue...
<iron-icon icon="arrow-forward" suffix></iron-icon>
</paper-button>
<span>Have an account already? Please <a href="{{baseUrl}}login">Login</a></span>
</paper-material>
</template>
<script>
Polymer({
is: 'my-registerform',
properties: {
email: {
type: String,
notify: true
}
},
handleRegisterTap: function(){
//this.$$('#main_pages').select("register/" + this.email);
}
});
function clearInput () {
document.querySelector('#email').value="";
}
</script>
问题是,我想重定向到这个部分,但我找不到方法,我尝试了:this.$$('#main_pages').select("register/" + this.email);
,但我得到了“找不到”。我很感谢你在这方面的帮助。
发布于 2016-03-22 01:28:26
我有办法解决这个问题:
handleRegisterTap: function(){
app.params = this.email;
app.route = 'register';
}
这样,我就自动得到了另一段的重定向。
https://stackoverflow.com/questions/36121858
复制相似问题