underscore.js 数组拆分新问题

发布于 2022-09-01 19:52:21 字数 1875 浏览 39 评论 0

var message  =message: 
                        [  {n:"jerry",a:"static/images/liuyan.jpg",from:"1", to: "10",msg:"在吗555",date:"2010-12-23"},
                           {n:"jerry",a:"static/images/liuyan.jpg",from:"1", to: "10",msg:"回来了吗",date:"2019-12-23"},
                           {n:"刘云",a:"static/images/ly.jpg",from:"10", to: "1",msg:"回来了:)",date:"2019-12-3"},
                           {n:"刘云",a:"static/images/ly.jpg",from:"10", to: "1",msg:"给你带了东西",date:"2019-12-23"},
                           {n:"刘云",a:"static/images/ly.jpg",from:'10', to: "1",msg:"累死了",date:"2012-1-1"},
                           {n:"jerry",a:"static/images/liuyan.jpg",from:"1", to: "10",msg:"在吗555bbbbbb",date:"2010-12-23"},
                           {n:"刘云",a:"static/images/ly.jpg",from:'10', to: "1",msg:"累死了333333",date:"2012-1-1"},

                        ];

拆分为:


 var message  =message: 
                        [  [{n:"jerry",a:"static/images/liuyan.jpg",from:"1", to: "10",msg:"在吗555",date:"2010-12-23"},
                           {n:"jerry",a:"static/images/liuyan.jpg",from:"1", to: "10",msg:"回来了吗",date:"2019-12-23"}],

                           [{n:"刘云",a:"static/images/ly.jpg",from:"10", to: "1",msg:"回来了:)",date:"2019-12-3"},
                            {n:"刘云",a:"static/images/ly.jpg",from:"10", to: "1",msg:"给你带了东西",date:"2019-12-23"},
                            {n:"刘云",a:"static/images/ly.jpg",from:'10', to: "1",msg:"累死了",date:"2012-1-1"}],

                           
                           [{n:"jerry",a:"static/images/liuyan.jpg",from:"1", to: "10",msg:"在吗555bbbbbb",date:"2010-12-23"}],
                           [{n:"刘云",a:"static/images/ly.jpg",from:'10', to: "1",msg:"累死了333333",date:"2012-1-1"}]

                        ];

每次收到对方的新消息,需要另起一行,如果一直是自己说话,内容还在这行里面。
如何用underscore 实现。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文