[英]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.