chore: resolve reflict

This commit is contained in:
zhuzhengjian 2023-03-17 15:48:39 +08:00
commit 6c7f67df60
5 changed files with 12 additions and 6 deletions

View File

@ -1,7 +1,7 @@
import { computed, defineComponent } from 'vue'
import { useProviderConfigState } from '../config-provider/context'
import useStyle from './style'
export default defineComponent({
const Button = defineComponent({
name: 'AButton',
inheritAttrs: false,
props: {
@ -9,7 +9,7 @@ export default defineComponent({
type: String
}
},
setup(props, { slots }) {
setup(props, { slots, attrs }) {
const { getPrefixCls } = useProviderConfigState()
const prefixCls = computed(() => getPrefixCls('btn', props.prefixCls))
const [wrapSSR, hashId] = useStyle(prefixCls)
@ -18,7 +18,9 @@ export default defineComponent({
[prefixCls.value]: true,
[hashId.value]: true
}
return wrapSSR(<button class={cls}>{slots.default?.()}</button>)
return wrapSSR(<button class={[cls, attrs.class]}>{slots.default?.()}</button>)
}
}
})
export default Button

View File

@ -77,6 +77,6 @@ export function useToken(): [ComputedRef<Theme<SeedToken, MapToken>>, ComputedRe
return [mergedTheme, computed(() => cacheToken.value?.[0]), computed(() => (designTokenContext.hashed ? cacheToken.value?.[1] : ''))]
}
export type UseComponentStyleResult = [(node: VNodeChild) => VNodeChild, string]
export type UseComponentStyleResult = [(node: VNodeChild) => VNodeChild, ComputedRef<string>]
export type GenerateStyle<ComponentToken extends object = AliasToken, ReturnType = CSSInterpolation> = (token: ComponentToken) => ReturnType

View File

@ -92,7 +92,7 @@ export default function genComponentStyleHook<ComponentName extends OverrideComp
flush(component, mergedComponentToken)
return [genCommonStyle(token.value, prefixCls.value), styleInterpolation]
}),
hashId.value
hashId
]
}
}

View File

@ -2,11 +2,13 @@ import type { Theme } from 'vitepress'
// eslint-disable-next-line import/no-named-as-default
import DefaultTheme from 'vitepress/theme'
import { AntdTheme } from 'vite-plugin-vitepress-demo/theme'
import Antd from '../../../components'
export default {
...DefaultTheme,
enhanceApp(ctx) {
DefaultTheme.enhanceApp?.(ctx)
ctx.app.component('Demo', AntdTheme)
ctx.app.use(Antd)
}
} as Theme

View File

@ -10,7 +10,9 @@ title: 基础按钮
<script lang="ts" setup></script>
<template>
<div></div>
<div>
<a-button>这是按钮</a-button>
</div>
</template>
<style scoped></style>