vue和jquery实现动态轮播table

<div class="grid-content table-content">
	<div id="divTableHeader">
    	<table class="table">
        	<thead>
            	<tr>
                	<th width="20%">内部模板号</th>
                    <th width="50%">模板名称</th>
                    <th width="15%">短信条数</th>
                    <th width="15%">是否超阈值</th>
                </tr>
            </thead>
        </table>
    </div>
    <div class="panel-body" id="divTable" style="padding:0;overflow:hidden;position:relative">
    	<div id="divTableContent" style="position:absolute;width:100%">
        	<table id="trueTable" class="table table-responsive table-striped">
            	<tbody>
               		<tr v-for="item in msgData"
                    	:style="{color:(item.overvalueOrNot==1?'#ff0000':'inherit')}">
	                	<td width="20%">{{item.templateID}}</td>
                        <td width="50%" style="padding-left: 20px;">{{item.templateName}}</td>
                        <td width="15%">{{item.msgNum}}</td>
                        <td width="15%">{{item.overvalueOrNot|transToChn}}</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>

表格滚动methods中方法:

tableScorll: function () {  //表格滚动
	var tableH = $('#divTableContent').outerHeight(true);
    var top = parseInt($('#divTableContent').css('top'));
    var bottom = parseInt($('#divTableContent').css('bottom'));
    var trH = $('#trueTable tr').outerHeight(true); //获取短信table tr的高度
    if ((bottom * -1) > trH) {
    	top -= trH;
    }
    else {
    	top += bottom;
    }
    if (top * (-1) >= tableH || bottom >= 0) {
    	top = 0;
        $('#divTableContent').animate({ 'top': top }, 200)
    }
    else {
    	$('#divTableContent').animate({ 'top': top }, 500)
    }
},

mounted挂载:

this.tableTimer = setInterval(() => {
	_this.tableScorll();    //短信table每2秒一滚动
}, 2000);
this.msgTimer = setInterval(() => {
	_this.setMsgData();      //调用方法获取告警table数据
}, 5000);

vue实例销毁时清除定时器:

if (this.msgTimer) {
	clearInterval(this.msgTimer); // 在Vue实例销毁前,清除短信table轮播定时器
};
if (this.tableTimer) {
	clearInterval(this.tableTimer); // 在Vue实例销毁前,清除滚动table轮播定时器
};
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值