代码仓库:https://github.com/Haixiang6123/tree-parser
代理均经过单元测试
曾经的我特别讨厌 LeetCode 算法题,当时就觉得写项目好玩,算法没什么用。不喜欢归不喜欢,为了面试,还是写了 476 道题 = =。非常感激默默地刷题的那段时光,在处理数据方面确实给了我不一样的思路。算法和数据结构果然还是基本功呀。
需求
我接到的需求很简单:后端返回一个 JSON,页面展示多个下拉选择器,根据用户不同的选择筛选不同的数据。例如:
而后端给我们的数据是这样的:
const data = {
'2020-10-10': {
success: {
text: [
{
name: '张三', content: '你好'},
{
name: '李四', content: '哈哈哈哈'},
{
name: '王五', content: 'EZEZ'},
],
audio: [
{
name: '小明', content: '喂喂喂'},
{
name: '小红', content: 'Hello'},
]
},
fail: {
text: [
{
name: '张三', content: 'Yoyoyo'},
{
name: '李四', content: 'yeyeye'},
{
name: '王五', content: 'rerere'},
],
audio: [
{
name: '小明', content: '失败了哦'},
{
name: '小红', content: '你好呀'},
]
},
sending: {
text: [
{
name: '张三', content: '正在发送'},
{
name: '李四', content: '发送着的文字'},
],
audio