簡體   English   中英

我可以在Polymer中以編程方式切換鐵頁嗎?

[英]Can I switch iron-pages programmatically in Polymer?

無論如何,如何在Polymer中以編程方式切換鐵頁? 我的意思是,我要在Polymer中完成操作時重定向頁面。

我知道,我可以使用window.location.href進行重定向,但需要以編程方式知道聚合物中的開關鐵頁。

_responseChanged: function(response) {
  console.log('response', response.applicationId);

  /*
    I want to redirect page here
  */

},

以下是三種方法

  • 調用selectNext函數,它將始終選擇下一頁
  • 調用select功能並傳遞您要select的頁碼
  • 您也可以直接更改Iron-pages的selected屬性(以下未介紹)

 <base href="https://polygit.org/components/"> <link rel="import" href="polymer/polymer.html"> <link rel="import" href="iron-pages/iron-pages.html"> <dom-module id="iron-page-select"> <template> <style></style> <iron-pages id="pages" selected="0"> <div on-tap="_selectNext">tap me to change to next page</div> <div on-tap="_selectCustom">tap me to change to 4th page</div> <div>three</div> <div>four</div> </iron-pages> </template> </dom-module> <script> Polymer({ is: 'iron-page-select', _selectNext: function() { this.$.pages.selectNext(); }, _selectCustom: function() { this.$.pages.select(3); } }) </script> <iron-page-select></iron-page-select> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM