簡體   English   中英

如果不重新點燃聚合物

[英]Polymer dom-if not re-firing

我的Polymer 2應用程序一直存在問題,我首先要解決的是路由問題,但是我發現在點擊該頁面后,當導航到該頁面時Dom-if觸發時,它並​​沒有重新觸發。

例如,

如果我使用的是url / matters / 6719,則會顯示詳細信息頁面,但是如果我單擊后退按鈕並轉到url / matters,則dom-if如果不再被點擊,它仍然會向我顯示詳細信息頁面,

使用我的導航選擇器時也會發生這種情況,該選擇器的設置類似於PWA入門套件。

<link rel="import" href="../bower_components/polymer/polymer-element.html">
<link rel="import" href="../bower_components/app-route/app-location.html">
<link rel="import" href="../bower_components/app-route/app-route.html">
<link rel="import" href="../bower_components/iron-pages/iron-pages.html">
<link rel="import" href="../bower_components/iron-selector/iron-selector.html">
<link rel="import" href="shared-styles.html">
<link rel="import" href="Matters/matter-list.html">
<link rel="import" href="MatParties/matparty-list.html">
<link rel="lazy-import" href="Matters/matter-detail.html">


<dom-module id="my-matters">


  <template>
    <style include="shared-styles">
      :host {
        display: block;

        padding: 10px;
      }
    </style>

    <app-route route="{{route}}" pattern="/:matter_id" data="{{routeData}}" tail="{{subroute}}">
      <app-route route="{{subroute}}" pattern="/matparties/:this_page" data="{{pageData}}"></app-route>
    </app-route>

    <div class="card">
        <template is="dom-if" if="[[_subidIsDefined(pageData.this_page)]]">
            <matparty-list linkedmatpartyid="[[pageData.this_page]]"></matparty-list>
          </template>
<template is="dom-if" if="[[!_subidIsDefined(pageData.this_page)]]">
      <template is="dom-if" if="[[!_idIsDefined(routeData.matter_id)]]">
        <matter-list></matter-list>
      </template>
      <template is="dom-if" if="[[_idIsDefined(routeData.matter_id)]]">
        <matter-detail linkedmatterid="[[routeData.matter_id]]"></matter-detail>
      </template>
</template>

  </template>

  <script>
    class Matters extends Polymer.Element {
      static get is() { return 'my-matters'; }


      _subidIsDefined(subid) {

        //There are probably ways to optimize this
        if (subid) {

          return true;
        }

        return false;
      }

      _idIsDefined(id) {

        //There are probably ways to optimize this
        if (id) {
          return true;
        }

        return false;
      }

    }
    window.customElements.define(Matters.is, Matters);
  </script>

</dom-module>

你檢查過圖案了嗎? 通常,該模式應遵循url模式。...在您的情況下為“ url / matters / 6719”

由於您已經在路由器和matparties上定義了pattern =“ / matparties /:this_page”,因此'url / matters / 6719'中的!='matters'可能會產生錯誤。 我不知道您是否定義了一個基本URL,它也會在這方面產生一些問題。

因此,網址應為matparties / 6719以匹配模式並解析為dom-if

暫無
暫無

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

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