V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
vv122483
V2EX  ›  问与答

要这么一个 JS 效果

  •  
  •   vv122483 · 2015-03-07 13:27:44 +08:00 · 1928 次点击
    这是一个创建于 3357 天前的主题,其中的信息可能已经有所发展或是发生改变。

    RT:手机上有一个聊天窗口,默认是这样写的,每条聊天都是append增加进去的,这样人少还好,人多的情况下,感觉会慢,有没有什么方法解决,当达到多少条聊天内容时,之前的聊天信息给remove掉,这样行吗,有没有更好的实现方法或者例子。求大神指教

    3 条回复    2015-03-07 20:03:41 +08:00
    Mutoo
        1
    Mutoo  
       2015-03-07 13:36:47 +08:00   ❤️ 1
    用 iscroll 效果 duang duang 的~ http://cubiq.org/iscroll-5
    kisshere
        2
    kisshere  
       2015-03-07 14:39:06 +08:00   ❤️ 2
    随便给你写个吧:
    setInterval("del_chat()",1000);
    var limit_count=100;//限制100条聊天记录
    function del_chat(){
    var chat_bubble_count=$('.chat_bubble').size();
    var rest_count=chat_bubble_count-limit_count;
    if(rest_count>0){//如果超出了100条聊天记录
    for(var i=0;i<rest_count;i++){
    $('.chat_bubble:eq('+i+')').remove();
    }
    }
    }
    vv122483
        3
    vv122483  
    OP
       2015-03-07 20:03:41 +08:00
    @kisshere 感谢感谢。受用!!!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1187 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 18:31 · PVG 02:31 · LAX 11:31 · JFK 14:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.