初学react这段代码怎么优化

data.map(function(value, index){
            //console.log('valueTitle = ', value.title)
            if( index< 6 ) {
                if( value.title === null || value.title === '') {
                    value.title ='(无视频标题)'
                }
                showDataDid01.push(value.title)
                showImageDid01.push(value['imageUrl'])
                showSource01.push(value['source'])
                showVideo01.push(value['videoUrl'])
                showImageWidth01.push(value['width'])
                showImageHeight01.push(value['height'])
            } else if ( index<12 ) {
                if( value.title === null || value.title === '') {
                    value.title ='(无视频标题)'
                }
                showDataDid02.push(value.title)
                showImageDid02.push(value['imageUrl'])
                showSource02.push(value['source'])
                showVideo02.push(value['videoUrl'])
                showImageWidth02.push(value['width'])
                showImageHeight02.push(value['height'])
            } else if ( index<18 ) {
                if( value.title === null || value.title === '') {
                    value.title ='(无视频标题)'
                }
                showDataDid03.push(value.title)
                showImageDid03.push(value['imageUrl'])
                showSource03.push(value['source'])
                showVideo03.push(value['videoUrl'])
                showImageWidth03.push(value['width'])
                showImageHeight03.push(value['height'])
            }
        })


_self.setState({
            videoGroupByPage: videoGroupByPage,
            pageQuantity: pageTotal,
            showData01: showDataDid01,
            showData02: showDataDid02,
            showData03: showDataDid03,
            showImage01: showImageDid01,
            showImage02: showImageDid02,
            showImage03: showImageDid03,
            showImageWidth01: showImageWidth01,
            showImageWidth02: showImageWidth02,
            showImageWidth03: showImageWidth03,
            showImageHeight01: showImageHeight01,
            showImageHeight02: showImageHeight02,
            showImageHeight03: showImageHeight03,
            showSource01: showSource01,
            showSource02: showSource02,
            showSource03: showSource03,
            showVideo01: showVideo01,
            showVideo02: showVideo02,
            showVideo03: showVideo03,
        })
阅读 859
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题