<template>
    <div class="es-information">
        <div
            v-for="(info, index) in rowList"
            :key="index"
            class="clearfix infoRow"
        >
            <es-info class="info" :info="dataList[index * 2]" :key="index">
            </es-info>
            <es-info
                :class="index * 2 < dataList.length - 1 ? 'info' : 'hide'"
                :info="
                    index * 2 < dataList.length - 1
                        ? dataList[index * 2 + 1]
                        : {}
                "
                :key="index * 2 + 1"
            >
            </es-info>
        </div>
    </div>
</template>
<script>
export default {
    name: 'es-information',
    props: {
        // 数组元素请参考info组件的info对象
        dataList: {
            type: Array,
            default() {
                return [];
            }
        }
    },
    data() {
        return {};
    },
    computed: {
        rowList: {
            get: function() {
                let count = Math.ceil(this.dataList.length / 2);
                let array = [];
                for (let i = 0; i < count; i++) {
                    array.push({});
                }
                return array;
            }
        }
    }
};
</script>
<style lang="scss" scoped>
.es-information {
    .infoRow {
        margin-top: 15px;
    }
    .info {
        width: 50%;
        float: left;
    }
}
</style>
