数组转换,帮忙看看可好?

图片说明
怎么才能把数组attrs转换成数组value

https://iask.sina.com.cn/b/Om4vIXsPW0H.html

如果但就这个数据的话不是用循环就可以了吗?
javascript

 let values = [];
    attrs[0].detail.map((item2) => {
      attrs[1].detail.map((item3)=>{
        values.push({value1:item2,value2:item3});
      })
    });

不知道你想要的是什么样的?


let attrs = ["A4","A3"]
    let detail = ["白色","红色"]
    function merage(attrs,detail){
        let len1 = attrs.length;
        let len2 = detail.length;
        let len = len1 * len2;

        let res = [];
        let i = 0;
        let j = 0;

        for(let i = 0; i < len; i++){
            let a = Math.floor(i/len2);
            let d = i % len2;
            res.push({
                v1: attrs[a],
                v2: detail[d]
            })
        }
        return res;
    }

    console.log(merage(attrs,detail));