<template>
  <component :is="myComponent" ref="detail" />
</template>
<script>
import { mapGetters } from 'vuex'
import groupDashboard from './group'
import pastureDashboard from './pasture'
import Cookies from 'js-cookie'
export default {
  name: 'Dashboard',
  components: { groupDashboard, pastureDashboard },
  data() {
    return {
      myComponent: null
    }
  },
  computed: {
    ...mapGetters(['ispastureuse'])
  },
  mounted() {
    this.detailComponent()
  },
  methods: {
    detailComponent() {
      if (Cookies.get('ispastureuse') == '1') {
        const vue = this
        var myComponent = () => import('./group/index.vue')
        return vue.myComponent = myComponent
      } else {
        const vue = this
        var myComponent = () => import('./pasture/index.vue')
        return vue.myComponent = myComponent
      }
    }

  }
}
</script>
