需求描述:最近需要写一个界面,主要功能是实现模态框的动态刷新
问题:可是涉及到自动刷新就有问题了,因为每次获取数据都是全量数据,用dataTable组装表格的话,页面会一直一直闪!里面绘制的表格会不断出现异常
如图这个是我做好的动态刷新,下面的请求是每隔5秒刷新一次,解决问题的主要方法如下(最终解决方法是在datatables的API 中找到的):
<template id="interface-statistics-modal" >
<div class="modal fade" id="secondary-modal" data-toggle="modal" tabindex="-1" role="dialog" >
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content" >
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<a class="pull-right help" >
<i class='fa fa-question-circle' ></i>
</a>
<h4 class="modal-title">{
{title}}</h4>
</div>
<div class="modal-body">
<table id="interface_statistics_table" class="table table-hover table-bordered table-striped">
<thead>
<tr>
<th>{
{$t('slb.vs_name')}}</th>
<th>{
{$t('slb.server_type')}}</th>
<th>{
{$t('net.ip_address')}}</th>
<th>{
{$t('net.status')}}</th>
<th>{
{$t('slb.connect_number')}}</th>
<th>{
{$t('slb.new_connect')}}</th>
<th>{
{$t('slb.HTTP_request_rate')}}</th>
<th>{
{$t('slb.request_flow')}}</th>
<th>{
{$t('slb.response_flow')}}</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
</template>
<script>