JS 生成商品sku

let arr = [
                [{
                    name: '红色',
                    value: '1'
                }, {
                    name: '黑色',
                    value: '2'
                }],
                [{
                    name: 'X',
                    value: '1'
                }, {
                    name: 'M',
                    value: '2'
                }],
                [{
                    name: '款式A',
                    value: '1'
                }, {
                    name: '款式B',
                    value: '2'
                }]
            ]
            let list = arr.reduce((a, b) => {
                    console.log(a,b)
                var ret = [];
                a.forEach(function(a) {
                    b.forEach(function(b) {
                        ret.push(a.concat([b]));
                    });
                })
                console.log(ret,'===============')
                return ret;
            }, [
                []
            ])
            console.log(list);

 

上一篇:336. 回文对


下一篇:多校联训2