base-vue支持组件库支持前缀类名
This commit is contained in:
1 parent
8f4c696bdd
commit
8bd73b3786
18 files changed
+266
-152
No files matched your search
@@ -1,26 +1,14 @@
|
||||
import type { PropType } from 'vue'
|
||||
import { defineComponent } from 'vue'
|
||||
import { computed, defineComponent } from 'vue'
|
||||
import { getPrefixCls } from '../_utils/getPrefixCls'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Button',
|
||||
name: 'AButton',
|
||||
props: {
|
||||
type: {
|
||||
type: String as PropType<'primary' | 'secondary' | 'danger' | 'link'>,
|
||||
default: 'primary',
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
type: { type: String as () => 'primary' | 'danger' | 'default', default: 'default' },
|
||||
},
|
||||
setup(props, { slots }) {
|
||||
const baseClass = 'btn'
|
||||
const typeClass = `btn-${props.type}`
|
||||
|
||||
return () => (
|
||||
<button class={`${baseClass} ${typeClass}`} disabled={props.disabled}>
|
||||
{slots.default?.()}
|
||||
</button>
|
||||
)
|
||||
const prefixCls = getPrefixCls('btn')
|
||||
const cls = computed(() => [prefixCls, `${prefixCls}-${props.type}`])
|
||||
return () => <button class={cls.value}>{slots.default?.()}</button>
|
||||
},
|
||||
})
|
||||
Reference in new issue
Block a user