0

我又来请教一个方法了。 掩面哭泣

 2 years ago
source link: https://www.v2ex.com/t/842804
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  程序员

我又来请教一个方法了。 掩面哭泣

  pianjiao · 23 小时 28 分钟前 · 2684 次点击
    const list = {
        email: {
            a: {
                big: {
                    rule: ['abig'],
                    isShow: true, 
                    extends: [] 
                },
                small: {
                    rule: ['asmall'],
                    isShow: false,
                    extends: [] 
                }
            },
            b: {
                big: {
                    rule: ['bbig'],
                    isShow: true, 
                    extends: [] 
                },
                small: {
                    rule: ['bsmall'],
                    isShow: false,
                    extends: [] 
                }
            },
        },
        qq: {
            a: {
                big: {
                    rule: ['abigqq'],
                    isShow: true, 
                    extends: [] 
                },
                small: {
                    rule: ['asmallqq'],
                    isShow: false,
                    extends: [] 
                }
            },
            b: {
                big: {
                    rule: ['bbigqq'],
                    isShow: true, 
                    extends: [] 
                },
                small: {
                    rule: ['bsmallqq'],
                    isShow: false,
                    extends: [] 
                }
            },
        },
    }

比如说 我传入了 a big 那么就取 qq 和 email 下 a => big 里面的转化成下面格式的 对象

    const data = {
        rule: {
            email: ['abigemail'],
            qq: ['abigqq']
        },
        ishow: {
            email: true,
            qq: false
        },
        extends: {
            email: [],
            qq: []
        }
    }

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK