Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/433.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript React JS lodash get在同一个函数中_Javascript_Reactjs_Lodash_Material Ui - Fatal编程技术网

Javascript React JS lodash get在同一个函数中

Javascript React JS lodash get在同一个函数中,javascript,reactjs,lodash,material-ui,Javascript,Reactjs,Lodash,Material Ui,我想使用Lodash get在同一行中显示字符串的两个对象?或者可以使用chain(u.chain(vehicle).get('test').get('test2')) 这是示例JSON文件 { "results": [ { "vehicle": { "plate_no": "ABC 1234", "model": "Toyota Innova" } }

我想使用Lodash get在同一行中显示字符串的两个对象?或者可以使用chain(u.chain(vehicle).get('test').get('test2'))

这是示例JSON文件

     {
      "results": [
        {
          "vehicle": {
            "plate_no": "ABC 1234",
            "model": "Toyota Innova"
          }
        }
      ]
    }
我使用的是MaterialUI卡,我的代码如下所示

  {_.map(this.state.vehicle, (d, idx) =>{
    return(
    <Col xs={6} style={{margin: '20px 0 5px' }}>
      <Card key={d.id}>
        <CardHeader
          avatar="http://lorempixel.com/100/100/nature/"
          title={_.get(d.vehicle, 'model') - _.get(d.vehicle, 'plate_no')}
          actAsExpander={true}
          showExpandableButton={true}
          style={{backgroundColor: Colors.grey200}}
        />
{{.map(this.state.vehicle,(d,idx)=>{
返回(
我的目标是显示标题,如下所示

  {_.map(this.state.vehicle, (d, idx) =>{
    return(
    <Col xs={6} style={{margin: '20px 0 5px' }}>
      <Card key={d.id}>
        <CardHeader
          avatar="http://lorempixel.com/100/100/nature/"
          title={_.get(d.vehicle, 'model') - _.get(d.vehicle, 'plate_no')}
          actAsExpander={true}
          showExpandableButton={true}
          style={{backgroundColor: Colors.grey200}}
        />
Toyota Innova-ABC 1234

您可以按所需的顺序使用所需的属性数组,然后数组#加入它们:

const d={
“车辆”:{
“车牌号”:“ABC 1234”,
“型号”:“丰田Innova”
}
};
const result=u.at(d.vehicle,['model','plate_no'])。连接('-');
console.log(结果);

Thank man:)它可以工作,但不知怎么回事?你不能使用两个lodash函数?你可以像在模板字符串中一样使用两个lodash函数-
.get()
。${{.get(d.vehicle,'model')}-${.get(d.vehicle,'plate'no')}。谢谢你的帮助:)