代码之家  ›  专栏  ›  技术社区  ›  Johan Byrén

聚合物2。在iron ajax响应后更改其他html页面(iron页面)上的值

  •  2
  • Johan Byrén  · 技术社区  · 7 年前

    当我用熨斗页面更改页面时,我想在新页面上设置值。属性具有正确的值,但html没有正确更新。

    这是我的页面。当我切换到此页面时,orderconfirmation值是正确的值。中的值 <td> 仍然是空字符串tho。

    <dom-module id="pn-bookpickup-confirmation">
    <template>
     <style include="main-styles">
    </style>
    <div class="confirmation-wrapper">
      <h3 class="center-header">{{localize("thankYou")}}</h3>
       <table>
         <tr>
          <td>{{localize("orderReference")}}:</td>
          <td class="font-weight-bold" id="orederRefId">{{orderconfirmation.orderreference}}</td>
        </tr>
      </table>
    </div>
    </template>
     <script>
     Polymer({
      is: "pn-bookpickup-confirmation",
      behaviors: [
        PnLocalizeBehavior
      ],
      properties: {
        language: {
          type: String,
          notify: true
        },
        orderconfirmation: {
          type: Object,
          notify: true,
          value: function () {
            return {
              pickuptime: "",
              orderreference: ""
            }
          }
         },
        },
       });
      </script>
     </dom-module>
    

    在我的主页中,在设置正确的值后,我切换到另一个页面:

      handleResponse: function (data) {
        console.log(data.detail.response);
        var response = data.detail.response.Item;
    
        this.orderconfirmation.orderreference = response.order.orderReference;
        this.orderconfirmation.pickuptime = response.order.operationDate; 
        this.selectedpage = "booking-confirmation";
      },
    

    因此,我想在重新保存数据时更改HTML中的orderconfirmation值。 谁知道我该怎么处理? 非常感谢。

    1 回复  |  直到 7 年前
        1
  •  2
  •   Cappittall    7 年前

    您提供的信息我建议您尝试: this.set this.set('orderconfirmation.orderreference', response.order.orderReference); this.set('orderconfirmation.pickuptime ', response.order.operationDate);

    使用集合方法对子属性进行可观察的更改。

    https://www.polymer-project.org/2.0/docs/devguide/model-data