27 lines
725 B
TypeScript
Raw Normal View History

2023-03-17 15:46:04 +08:00
import { computed, defineComponent } from 'vue'
import { useProviderConfigState } from '../config-provider/context'
import useStyle from './style'
2023-03-10 22:11:33 +08:00
const Button = defineComponent({
2023-03-08 16:10:20 +08:00
name: 'AButton',
2023-03-17 15:46:04 +08:00
inheritAttrs: false,
props: {
prefixCls: {
type: String
}
},
2023-03-17 15:48:39 +08:00
setup(props, { slots, attrs }) {
2023-03-17 15:46:04 +08:00
const { getPrefixCls } = useProviderConfigState()
const prefixCls = computed(() => getPrefixCls('btn', props.prefixCls))
const [wrapSSR, hashId] = useStyle(prefixCls)
2023-03-08 16:10:20 +08:00
return () => {
2023-03-17 15:46:04 +08:00
const cls = {
[prefixCls.value]: true,
[hashId.value]: true
}
2023-03-17 15:48:39 +08:00
return wrapSSR(<button class={[cls, attrs.class]}>{slots.default?.()}</button>)
2023-03-08 16:10:20 +08:00
}
}
})
2023-03-10 22:11:33 +08:00
export default Button