<template>
  <div class="app-container">
    <el-tabs v-model="activeName" @tab-click="handleTabClick">
      <el-tab-pane
:label="$t('defaultParameter.name1')" name="first">
        <component :is="myComponent1" ref="detail1" />
      </el-tab-pane>
      <el-tab-pane :label="$t('defaultParameter.name2')" name="second">
        <component :is="myComponent2" ref="detail2" />
      </el-tab-pane>
    </el-tabs>
  </div>

</template>

<script>
import Function from './function/index'
import EarlyWarning from './earlyWarning/index'
export default {
  name: 'DefaultParameter',
  components: { Function, EarlyWarning },
  data() {
    return {
      activeName: 'first',
      myComponent1: null,
      myComponent2: null
    }
  },
  created() {
    this.detailComponent()
  },

  methods: {
    detailComponent() {
      if (this.activeName == 'first') {
        const vue = this
        var myComponent1 = () => import('./function/index.vue')
        return vue.myComponent1 = myComponent1
      } else if (this.activeName == 'second') {
        const vue = this
        var myComponent2 = () => import('./earlyWarning/index.vue')
        return vue.myComponent2 = myComponent2
      }
    },
    handleTabClick() {
      if (this.activeName == 'first') {
        const vue = this
        var myComponent1 = () => import('./function/index.vue')
        return vue.myComponent1 = myComponent1
      } else if (this.activeName == 'second') {
        const vue = this
        var myComponent2 = () => import('./earlyWarning/index.vue')
        return vue.myComponent2 = myComponent2
      }
    }

  }
}
</script>
<style lang="scss" scoped>

</style>
