简体   繁体   English

通过纸上按键轻按事件进行路由

[英]Routing with paper-button on-tap event

I'm having an issue with routing inside my web app, the problem is that I have a different sections in my index.html and on one of those sections I have a paper-button element so I would like to routing to other section when the user tap on this button, here is some code so you could understand better: 我在Web应用程序内部路由时遇到问题,问题是我的index.html中有不同的部分,而在其中一个部分中,我有一个纸按钮元素,因此我想在用户点击此按钮,下面是一些代码,因此您可以更好地理解:

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>

The section that contain the element with the button is: home and the element is: my-register . 包含带有按钮的元素的部分是: home ,而元素是: my-register

routing.html routing.html

page('/register/:email', function(data) {
  app.route = 'register';
  app.params = data.params;
});

Above is the function in the routing.html.Where I declared that I'm going to received the url /register/:email and I will redirect to the register section. 上面是routing.html中的函数,我在这里声明将接收URL /register/:email然后将重定向到register部分。

my-register.html 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>

The problem is that I want to redirect to the section but I can't find a way to do it, I tried: this.$$('#main_pages').select("register/" + this.email); 问题是我想重定向到该部分,但我找不到解决方法,我尝试过: this.$$('#main_pages').select("register/" + this.email); but I got "not found". 但我“找不到”。 I appreciate any help on that. 我对此表示感谢。

I got a solution for this: 我对此有一个解决方案:

handleRegisterTap: function(){
            app.params = this.email;
            app.route = 'register';
        }

In that way automatically i got a redirect to the other section. 这样,我自动重定向到另一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM