我遇到一个问题,ajax请求没有更新UI。我需要手动刷新页面。
基本上它是一个类似按钮。按下时,它应该会增加点赞数。HTTP请求和响应工作正常。但是值CCD_ 1不会立即得到更新。
<template>
<form is="iron-form" id="likeForm" method="post" action="/like/{{commentaire.heure}}" on-click="submitLike" on-iron-form-response="augmenterLikes">
<paper-button raised>{{commentaire.likes}} J'aime</paper-button>
</form>
</template>
<script>
Polymer({
is: 'my-comment',
properties: {
commentaire : {
type: Object,
value: {},
},
},
augmenterLikes: function(e) {
this.commentaire.likes = e.detail.response;
},
});
如有任何帮助,我们将不胜感激。
为了更新深层属性,您必须使用set
方法,例如:
this.set('commentaire.likes', e.detail.response);
我在这里用一个随机数生成器做了一个例子:https://jsfiddle.net/fLbf6uag/1/