index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*home*/
  2. <template>
  3. <div ref="home" class="home">
  4. <el-carousel
  5. :height="height"
  6. :trigger="trigger"
  7. :interval="interval"
  8. :indicator-position="indicator"
  9. :arrow="arrow"
  10. :autoplay="autoplay"
  11. :loop="true"
  12. :direction="direction"
  13. >
  14. <el-carousel-item v-for="(item, index) in bannerList" :key="index">
  15. <img class="banner" :src="item.url" />
  16. </el-carousel-item>
  17. </el-carousel>
  18. </div>
  19. </template>
  20. <script>
  21. export default {
  22. name: 'Home',
  23. components: {},
  24. data() {
  25. return {
  26. bannerList: [
  27. { url: require('../../../assets/banner/banner1.png') },
  28. { url: require('../../../assets/banner/banner1.png') },
  29. { url: require('../../../assets/banner/banner1.png') },
  30. ],
  31. height: '500px',
  32. trigger: 'click', // indicator的触发方式click/hover
  33. interval: 5000, // 自动切换的时间间隔,单位为毫秒
  34. indicator: 'none', // indicator的位置outside/none
  35. arrow: 'never', // 切换箭头的显示时机always/hover/never
  36. autoplay: false, // 是否自动切换true/false
  37. direction: 'horizontal', // 展示的方向horizontal/vertical
  38. }
  39. },
  40. watch: {
  41. $route: {
  42. handler: function (route) {
  43. if (route.query && route.query.type == 'reLogin') {
  44. this.toLogin()
  45. }
  46. },
  47. immediate: true,
  48. },
  49. },
  50. inject: ['toLogin'],
  51. created() {
  52. let messageBoxArr = document.getElementsByClassName(
  53. 'el-message-box__wrapper'
  54. ) //获取页面所有已经存在的messageBox
  55. if (messageBoxArr.length > 0) {
  56. this.$msgbox.close() //关闭messageBox弹框
  57. }
  58. },
  59. mounted() {
  60. let _this = this
  61. if (_this.$route.path.indexOf('/indexLayout/home') != -1) {
  62. _this.setHeight()
  63. window.addEventListener('resize', function () {
  64. _this.setHeight()
  65. })
  66. }
  67. },
  68. methods: {
  69. // setHeight() {
  70. // console.log(this.$refs.home.clientWidth)
  71. // this.height = (720 / 1920) * this.$refs.home.clientWidth + 'px'
  72. // },
  73. },
  74. }
  75. </script>
  76. <style lang="scss" scoped>
  77. @import '@/styles/variables.scss';
  78. @import '@/styles/mixin.scss';
  79. .home {
  80. // @include w_h(100%, 100%);
  81. @include w_h(100%);
  82. font-size: 12px;
  83. color: $color_b;
  84. background: #181818;
  85. .banner {
  86. @include w_h(100%);
  87. }
  88. }
  89. </style>
  90. <style lang="scss">
  91. @import '@/styles/variables.scss';
  92. @import '@/styles/mixin.scss';
  93. .home {
  94. .el-carousel__container {
  95. @include w_h(100%);
  96. .el-carousel__item {
  97. @include w_h(100%);
  98. }
  99. }
  100. .el-carousel--horizontal {
  101. overflow: hidden;
  102. }
  103. .el-carousel__arrow {
  104. background: rgba(31, 45, 61, 0.4);
  105. &:hover {
  106. background: rgba(31, 45, 61, 0.8);
  107. }
  108. }
  109. }
  110. </style>