index.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <div class="app-container">
  3. <el-tabs v-model="activeName" @tab-click="handleTabClick">
  4. <el-tab-pane
  5. :label="$t('defaultParameter.name1')" name="first">
  6. <component :is="myComponent1" ref="detail1" />
  7. </el-tab-pane>
  8. <el-tab-pane :label="$t('defaultParameter.name2')" name="second">
  9. <component :is="myComponent2" ref="detail2" />
  10. </el-tab-pane>
  11. </el-tabs>
  12. </div>
  13. </template>
  14. <script>
  15. import Function from './function/index'
  16. import EarlyWarning from './earlyWarning/index'
  17. export default {
  18. name: 'DefaultParameter',
  19. components: { Function, EarlyWarning },
  20. data() {
  21. return {
  22. activeName: 'first',
  23. myComponent1: null,
  24. myComponent2: null
  25. }
  26. },
  27. created() {
  28. this.detailComponent()
  29. },
  30. methods: {
  31. detailComponent() {
  32. if (this.activeName == 'first') {
  33. const vue = this
  34. var myComponent1 = () => import('./function/index.vue')
  35. return vue.myComponent1 = myComponent1
  36. } else if (this.activeName == 'second') {
  37. const vue = this
  38. var myComponent2 = () => import('./earlyWarning/index.vue')
  39. return vue.myComponent2 = myComponent2
  40. }
  41. },
  42. handleTabClick() {
  43. if (this.activeName == 'first') {
  44. const vue = this
  45. var myComponent1 = () => import('./function/index.vue')
  46. return vue.myComponent1 = myComponent1
  47. } else if (this.activeName == 'second') {
  48. const vue = this
  49. var myComponent2 = () => import('./earlyWarning/index.vue')
  50. return vue.myComponent2 = myComponent2
  51. }
  52. }
  53. }
  54. }
  55. </script>
  56. <style lang="scss" scoped>
  57. </style>