English 中文(简体)
• 如何进口诸如“千变”等房地产的规格类型?
原标题:How to import typescript types for vuetify properties like "variant"?

我正在根据从武库3号楼起伏打造一个假装部件。 我想有一种变式财产,转而使用原部分一。 我要正确指出这些类型。 目前我的类型定义

 variant?: NonNullable<"flat" | "text" | "elevated" | "tonal" | "outlined" | "plain"> | undefined,

难道我能以某种方式从v-btn进口这一名词? 我不喜欢把变数清单复制到我的代码基。 我愿谈一下。

variant?: Variant | undefined

更多。

这是我努力建设的组成部分:

<template>
    <v-tooltip location="bottom">
        <template v-slot:activator="{ props }">
            <v-btn v-bind="props" icon class="icon-right" @click="$emit( onClick )" :variant="$props.variant" :density="$props.density">
            <v-icon> {{ $props.icon }} </v-icon>
            </v-btn>
        </template>
        <span> {{ $props.title }} </span>
    </v-tooltip>
</template>
  
<style scoped lang="scss">
.icon-right {
  position: absolute;
  right: 0;
  margin-bottom: 2rem;
}
</style>

<script lang="ts" setup>
const props = defineProps<{
  title: string,
  icon: string,
  variant?: NonNullable<"flat" | "text" | "elevated" | "tonal" | "outlined" | "plain"> | undefined,
  density?: null |  default  |  comfortable  |  compact ,
}>();
const emit = defineEmits<{
  onClick: []
}>();
</script>
问题回答

您可从“地理/成分”进口<代码>进口类型{VBtn }。

import type { VBtn } from "vuetify/components";

type TVariant = VBtn["$props"][ variant ];
type TDensity = VBtn["$props"][ density ];
const props = defineProps<{
  title: string;
  icon: string;
  variant?: TVariant;
  density?: TDensity;
}>();




相关问题
Nuxt 3 useRoute import cannot find

I am using latest nuxt version and when I tried to use the useRoute method is triggers a "Cannot Find name useRoute" but it works so I would like to know what could I be missing My package ...

Vue array dependent select not display data

I have dependent selection like this. Selection image when i console log, they have data but not render data in selection data This is what i ve tried. for Product selection has default selected value ...

How to inject Bearer Token in Axios boot file

Quasar has a different setup using boot files and my current axios.ts looks liek this: import { boot } from quasar/wrappers ; import axios, { AxiosInstance } from axios ; declare module @vue/...

Vue router and Vite Base url conflict

I use Vue Router to develop my single page application and use Vite to package my project. I want to deploy all static files (such as index.js and index.css) under another CDN domain name (cdn.example....

Vue.js change class on mounted

I have a button element with a .hover property and I need the hover animation to also happen as soon as the page is mounted. How can I attribute a class to a button on the mounted function and then ...

Laravel +Vuejs CORS issue

I am facing a dilemma wit the CORS issue. I have application that is configured as follow: API: https://abc.mydomain.com (laravel) front end: https://subdomain.mydomain.com(VueJS) Both applications ...

热门标签