我不是专业前端,能给出具体代码的建议吗?先谢过了!
现在的场景是:web端-vue-前端需要实时的展示刷新一个结果数据,这个数据普遍在2000条左右。后端使用socket在实时的推送,因为需要消息的实时性,所以后端会一直推,速度大概是七八百条/秒。前端需要用什么方法有效的渲染这个数据,或者后端需要怎么的改进。(这里有一个实际的问题:数据需要实时性,后端这边一直获取最新信息然后推送给前端。)
前端局部展示代码:
// 渲染部分
<div v-for="item in listinfo">
<el-tag effect="plain" type="info" style="display: block;border: none;font-size: 14px" >
{{item}}
</el-tag>
</div>
<div v-for="item in listinfo1">
<el-tag effect="plain" type="info" style="display: block;border: none;font-size: 14px" >
{{item}}
</el-tag>
</div>
//参数部分
export default {
name: "case",
components: {},
data() {
listinfo: [],
listinfo1: [],
}
}
// socket部分
connectsocket(){
let url = 'ws://.....';
this.ws = new websocket(url)
this.ws.onmessage = function(e){
var text = JSON.parse(e.data)
if (typeof text.message==="string"){
if(text.message==="start"){
that.getList()
that.getTreeselect()
that.exeAbel = true
that.readOnly = true
}else if(text.message==='end'){
that.result()
that.getList()
that.getTreeselect()
that.exeAbel = false
that.readOnly = false
}else if(text.msg_type==='run'){
that.infolist.push(text.message)
}else if(text.msg_type==='run1'){
that.infolist1.push(text.message)
}
}else if(typeof text.message==="object"){
//这个消息数量很少,就不写了
}
}
}