Blame view

src/ui/vant-weapp/action-sheet/index.js 1.38 KB
simon committed
1 2 3 4 5 6
import { VantComponent } from '../common/component';
VantComponent({
    props: {
        show: Boolean,
        title: String,
        cancelText: String,
simon committed
7 8 9 10 11
        description: String,
        round: {
            type: Boolean,
            value: true
        },
simon committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
        zIndex: {
            type: Number,
            value: 100
        },
        actions: {
            type: Array,
            value: []
        },
        overlay: {
            type: Boolean,
            value: true
        },
        closeOnClickOverlay: {
            type: Boolean,
            value: true
simon committed
27 28 29 30 31 32 33 34
        },
        closeOnClickAction: {
            type: Boolean,
            value: true
        },
        safeAreaInsetBottom: {
            type: Boolean,
            value: true
simon committed
35 36 37 38 39 40 41 42
        }
    },
    methods: {
        onSelect(event) {
            const { index } = event.currentTarget.dataset;
            const item = this.data.actions[index];
            if (item && !item.disabled && !item.loading) {
                this.$emit('select', item);
simon committed
43 44 45
                if (this.data.closeOnClickAction) {
                    this.onClose();
                }
simon committed
46 47 48 49 50 51 52
            }
        },
        onCancel() {
            this.$emit('cancel');
        },
        onClose() {
            this.$emit('close');
simon committed
53 54 55 56
        },
        onClickOverlay() {
            this.$emit('click-overlay');
            this.onClose();
simon committed
57 58 59
        }
    }
});