我遇到了VueJS渲染的问题。我正在通过Ajax获取数据。在初始渲染时,表格行被渲染为正确的,但是在重新渲染更新的元素时,它不会被正确渲染。VueJS 2重新渲染表
这里有一个画面: Rendered Table
正如你所看到的,列#1呈现的右。但在重新渲染的第2行中,tds被倒置。
这里是我的代码:
var renderings = new Vue({
el: '#renderings',
data: function() {
return {
hasUnprocessedRenderings: false,
renderings: {}
};
},
methods: {
clearData: function() {
this.renderings = {};
},
updateData: function() {
this.$http.get('http://some-url.com/renderings').then(function (response) {
this.renderings = response.body.renderings;
this.hasUnprocessedRenderings = response.body.hasUnprocessedRenderings;
if (this.hasUnprocessedRenderings) {
setTimeout(this.updateData, 10000);
}
});
}
},
mounted: function() {
this.updateData();
}
});
和我的html:
<div id="renderings">
<table class="table table-striped table-hover table-bordered" style="margin bottom: 0;">
<thead>
<tr>
<th>Personalisierung</th>
<th>Format</th>
<th>Download</th>
<th></th>
</tr>
</thead>
<tbody>
<template v-for="rendering in renderings">
<tr>
<td>{{rendering.personalizationName}}</td>
<td>{{rendering.renderTypeName}}</td>
<template v-if="rendering.DOCUMENT_URL">
<td><a :href="rendering.DOCUMENT_URL">{{rendering.DOCUMENT_URL}}</a></td>
<td>
<ul class="list-inline" style="margin-bottom: 0;">
<li><a :href="'http://some-url.com?pid='+rendering.PROCESS_ID" title="refresh"><i class="fa fa-refresh" aria-hidden="true"></i></a></li>
<li><a :href="'http://some-url.com?pid='+rendering.PROCESS_ID" title="delete"><i class="fa fa-trash-o" aria-hidden="true"></i></a></li>
</ul>
</td>
</template>
<template v-else>
<td colspan="2" style="text-align: center;">
<i class="fa fa-cog fa-spin fa-fw"></i>
<span>In Bearbeitung..</span>
</td>
</template>
</tr>
</template>
</tbody>
</table>
</div>
所以我的问题:我该如何解决,该行是越来越正确地重新渲染?
感谢您的任何帮助。 :-)
编辑#1: 这里有一个的jsfiddle,那里的问题也会发生:https://jsfiddle.net/dt1kt06g/
除了模板中的语法错误(单引号在' Aletheios
我已经用我的代码和一些数据添加了jsfiddle,并修复了语法错误。问题也出现在那里, – Hendrik