<template>
  <div class="empty-data__wrap" v-if="visible">
    <van-loading v-if="loading" type="spinner" size="0.4rem" />
    <span v-else class="empty-data__text">暂无数据...</span>
  </div>
</template>
<script>
import Vue from 'vue'
import { Loading } from 'vant'

Vue.use(Loading)

export default {
  name: 'list_empty_data_cell',
  props: {
    data: [Array, Object, Boolean, Number],
    loading: { type: Boolean, default: false }
  },
  computed: {
    visible() {
      if (Array.isArray(this.data)) {
        return this.data.length === 0
      } else {
        return !this.data
      }
    }
  }
}
</script>
<style lang="less" scoped>
.empty-data__wrap {
  position: relative;
  display: flex;
  padding: 0.24rem 0;
  align-items: center;
  justify-content: center;
}

.empty-data__text {
  font-size: 0.28rem;
  color: #aaa;
}
</style>