<template>
  <!-- <n-image v-if="getProps.src" v-bind="getProps" /> -->
  <n-image v-for="(item,index) in getProps" v-show="index < limit" :key="index" v-bind="item" />
</template>

<script>
import { defineComponent, computed, toRaw } from 'vue'
import { isArray } from '@/utils/is.js'
export default defineComponent({
  name: 'TableImage',
  props: {
    images: {
      type: Object,
      default: null,
      required: true
    },
    limit: {
      type: Number,
      default: 1
    }
  },
  setup(props, { emit }) {
    const getProps = computed(() => {
      const images = { ...toRaw(props.images) }
      let list = []
      if (isArray(images.src)) {
        list = images.src
      }
      if (images.src) {
        list = images.src.split(',')
      }
      return list.map((item) => {
        return {
          ...toRaw(props.images),
          src: item
        }
      })
    })

    return {
      getProps
    }
  }
})

</script>

<style scoped lang='scss'>
</style>
