app-mob-icon.vue 1.1 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
<template>
        <ion-icon class='app-mob-icon' :name="parsedName" :size="size" :slot="position" @click.stop="onClick" ></ion-icon>
</template>

<script lang="ts">
import { Component, Vue, Prop, Watch } from 'vue-property-decorator';
import { ViewTool } from "ibiz-core";
@Component({})
export default class AppMobIcon extends Vue {
    /**
     * 图标name属性
     * 
     * @type {*}
     * @memberof AppMobIcon
     */
    @Prop() public name: any;

    /**
     * 图标位置
     * 
     * @type {*}
     * @memberof AppMobIcon
     */
    @Prop() public position: any;

    /**
     * 图标尺寸size
     * 
     * @type {*}
     * @memberof AppMobIcon
     */
    @Prop() public size: any;

    /**
     * 监听图标名称变化
     */
    @Watch('name', { immediate: true })
    public iconNameChange(newVal: any, oldVal: any){
        if (newVal) {
          this.parsedName = ViewTool.setIcon(newVal);
        }
    }

    /**
     * 解析后的图标名称
     */
     public parsedName:string = '';

    /**
     * 图标点击事件
     * 
     * @memberof AppMobIcon
     */
    public onClick(){
        this.$emit('onClick');
    }   
}
</script>