如何在javascript中添加多值数组作为对象数组的子元素

问题描述

我有两个数组,我想添加一个数组作为另一个数组的子元素。有一些类似的东西,但对我不起作用。

const bodyContainer = [
    {
      messageId: 'msg001',message: 'test message 1'
    },{
      messageId: 'msg002',message: 'test message 2'
    },{
      messageId: 'msg003',message: 'test message 3'
    }];

const user = [{
      id: 'user01',chatHistory: //here I want to add the "bodyContainer" array as a sub array (not like a single-line string value)
    }];

我该怎么做?有人可以帮忙吗?谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)