123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- /*home*/
- <template>
- <div ref="home" class="home">
- <el-carousel
- :height="height"
- :trigger="trigger"
- :interval="interval"
- :indicator-position="indicator"
- :arrow="arrow"
- :autoplay="autoplay"
- :loop="true"
- :direction="direction"
- >
- <el-carousel-item v-for="(item, index) in bannerList" :key="index">
- <img class="banner" :src="item.url" />
- </el-carousel-item>
- </el-carousel>
- </div>
- </template>
- <script>
- export default {
- name: 'Home',
- components: {},
- data() {
- return {
- bannerList: [
- { url: require('../../../assets/banner/banner1.png') },
- { url: require('../../../assets/banner/banner1.png') },
- { url: require('../../../assets/banner/banner1.png') },
- ],
- height: '500px',
- trigger: 'click', // indicator的触发方式click/hover
- interval: 5000, // 自动切换的时间间隔,单位为毫秒
- indicator: 'none', // indicator的位置outside/none
- arrow: 'never', // 切换箭头的显示时机always/hover/never
- autoplay: false, // 是否自动切换true/false
- direction: 'horizontal', // 展示的方向horizontal/vertical
- }
- },
- watch: {
- $route: {
- handler: function (route) {
- if (route.query && route.query.type == 'reLogin') {
- this.toLogin()
- }
- },
- immediate: true,
- },
- },
- inject: ['toLogin'],
- created() {
- let messageBoxArr = document.getElementsByClassName(
- 'el-message-box__wrapper'
- ) //获取页面所有已经存在的messageBox
- if (messageBoxArr.length > 0) {
- this.$msgbox.close() //关闭messageBox弹框
- }
- },
- mounted() {
- let _this = this
- if (_this.$route.path.indexOf('/indexLayout/home') != -1) {
- _this.setHeight()
- window.addEventListener('resize', function () {
- _this.setHeight()
- })
- }
- },
- methods: {
- // setHeight() {
- // console.log(this.$refs.home.clientWidth)
- // this.height = (720 / 1920) * this.$refs.home.clientWidth + 'px'
- // },
- },
- }
- </script>
- <style lang="scss" scoped>
- @import '@/styles/variables.scss';
- @import '@/styles/mixin.scss';
- .home {
- // @include w_h(100%, 100%);
- @include w_h(100%);
- font-size: 12px;
- color: $color_b;
- background: #181818;
- .banner {
- @include w_h(100%);
- }
- }
- </style>
- <style lang="scss">
- @import '@/styles/variables.scss';
- @import '@/styles/mixin.scss';
- .home {
- .el-carousel__container {
- @include w_h(100%);
- .el-carousel__item {
- @include w_h(100%);
- }
- }
- .el-carousel--horizontal {
- overflow: hidden;
- }
- .el-carousel__arrow {
- background: rgba(31, 45, 61, 0.4);
- &:hover {
- background: rgba(31, 45, 61, 0.8);
- }
- }
- }
- </style>
|