mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
types(Badge): improve typing
This commit is contained in:
parent
d86238f071
commit
1b96a45d0b
@ -2,13 +2,18 @@ import { isDef, createNamespace } from '../utils';
|
||||
|
||||
const [createComponent, bem] = createNamespace('badge');
|
||||
|
||||
export type BadgeProps = {
|
||||
dot?: boolean;
|
||||
badge?: number | string;
|
||||
};
|
||||
|
||||
export default createComponent({
|
||||
props: {
|
||||
dot: Boolean,
|
||||
badge: [Number, String],
|
||||
},
|
||||
|
||||
setup(props) {
|
||||
setup(props: BadgeProps) {
|
||||
return () => {
|
||||
const { dot, badge } = props;
|
||||
const hasBadge = isDef(badge) && badge !== '';
|
@ -2,16 +2,16 @@
|
||||
* Create a basic component with common options
|
||||
*/
|
||||
import { camelize } from '../format/string';
|
||||
import type { App, ComponentOptions } from 'vue';
|
||||
import { App, defineComponent, ComponentOptionsWithObjectProps } from 'vue';
|
||||
|
||||
export function createComponent(name: string) {
|
||||
return function (sfc: ComponentOptions) {
|
||||
return function (sfc: ComponentOptionsWithObjectProps) {
|
||||
sfc.name = name;
|
||||
sfc.install = (app: App) => {
|
||||
app.component(name as string, sfc);
|
||||
app.component(camelize(`-${name}`), sfc);
|
||||
};
|
||||
|
||||
return sfc;
|
||||
return defineComponent(sfc);
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user