app-mob-menu-swiper-view.vue 1.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
<template>
    <ion-card class="app-mob-menu-swiper-view">
        <ion-card-content class="app-mob-menu-swiper-view__content">
            <ion-slides ref="swipers" pager="true">
                <template v-for="item in items">
                    <ion-slide :key="item.id" @click="selectItem(item.name)" >
                        <img v-if="item.icon != ''" :src="item.icon"/>
                    </ion-slide>
                </template>
            </ion-slides>
        </ion-card-content>
    </ion-card>
</template>

<script lang="ts">
import { Vue, Component, Prop, Emit } from 'vue-property-decorator';
@Component({
    components: {
    }
})
export default class AppMobMenuSwiperView extends Vue {
    /**
     * 菜单名称
     *
     * @type {string}
     * @memberof AppMobMenuSwiperView
     */
    @Prop() public menuName!: string;

    /**
     * 菜单数据项
     *
     * @type {Array<any>}
     * @memberof AppMobMenuSwiperView
     */
    @Prop() public items!: Array<any>;


    /**
     * 菜单选中事件
     *
     * @param {*} val
     * @returns
     * @memberof AppMobMenuSwiperView
     */
    @Emit()
    select(val: any) {
        return val;
    }

    /**
     * 选中菜单项
     *
     * @param {string} name
     * @memberof AppMobMenuSwiperView
     */
    public selectItem(name: string): void {
        this.select(name);
    }
    
    /**
     * 自动轮播
     * 
     * @memberof AppMobMenuSwiperView
     */
    public mounted(){
      let slides:any = document.querySelector('ion-slides');
      slides.options = {
          speed: 500,
          autoplay:{
            delay:500
          },
          loop:true
      };
    }
}
</script>