使用纸按钮点击事件进行路由

Routing with paper-button on-tap event

我的网络应用程序内部有路由问题,问题是我的 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 中的函数。我声明我将接收 url /register/:email 并且我将重定向到寄存器部分。

我的-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);但我得到了 "not found"。 我很感激任何帮助。

我找到了解决方案:

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

通过这种方式,我会自动重定向到其他部分。