代码示例:https://github.com/maxsky/imitate-tb-combo-select
Demo 演示:https://codepen.io/maxsky/pen/oNLWgNp
1function calcDescartes (array) { 2 if (array.length < 2) return array[0] || []; 3 4 return [].reduce.call(array, function (col, set) { 5 var res = []; 6 7 col.forEach(function (c) { 8 set.forEach(function (s) { 9 var t = [].concat(Array.isArray(c) ? c : [c]); 10 t.push(s); 11 res.push(t); 12 }) 13 }); 14 15 return res; 16 }); 17} 18 19console.log(calcDescartes([[1,2,3],['a','b','c']]));
在 Chrome 运行一下:

