<template>
|
<nut-button v-if="props.access" v-bind="omitAttrs" :open-type="attrs['open-type']">
|
<template v-for="(item, key, i) in $slots" :key="i" v-slot:[key]>
|
<slot :name="key"></slot>
|
</template>
|
</nut-button>
|
<nut-button v-else v-bind="omitAttrs" @click="emit('noAccess')">
|
<template v-for="(item, key, i) in $slots" :key="i" v-slot:[key]>
|
<slot :name="key"></slot>
|
</template>
|
</nut-button>
|
</template>
|
|
<script setup lang="ts">
|
import _ from 'lodash';
|
import { useAttrs, computed } from 'vue';
|
|
defineOptions({
|
name: 'AccessOpenTypeButton',
|
inheritAttrs: false,
|
});
|
|
const props = defineProps<{
|
access?: boolean;
|
}>();
|
|
const emit = defineEmits<{
|
(e: 'noAccess'): void;
|
}>();
|
|
const attrs = useAttrs();
|
|
const omitAttrs = computed(() => _.omit(attrs, ['open-type']));
|
</script>
|