<template>
  <div class="lanaya-tree-view">
    <div class="lanaya-tree-view--no-data" v-if="noData">
      <span class="lanaya-tree-view__text">没有数据...</span>
    </div>
    <l-tree-view-item v-for="(item, index) in tree.data"
                      v-if="!noData"
                      :tree-entity="tree"
                      :level="1"
                      :key="index"
                      :format="tree.format"
                      :option="item">
    </l-tree-view-item>
  </div>
</template>
<script>
import TreeView from './TreeViewEntity';
import LTreeViewItem from './TreeViewItem';

export default {
  name: 'LTreeView',
  components: {
    LTreeViewItem
  },
  props: {
    tree: {
      type: TreeView,
      default: new TreeView({})
    }
  },
  computed: {
    noData () {
      return this.tree.data.length < 1;
    }
  }
};
</script>
