[improvement] ContactCard: tsx (#2781)
This commit is contained in:
@@ -2,9 +2,26 @@ import { use } from '../utils';
|
||||
import { emit, inherit } from '../utils/functional';
|
||||
import Cell from '../cell';
|
||||
|
||||
// Types
|
||||
import { CreateElement, RenderContext } from 'vue/types';
|
||||
import { DefaultSlots } from '../utils/use/sfc';
|
||||
|
||||
const [sfc, bem, t] = use('contact-card');
|
||||
|
||||
function ContactCard(h, props, slots, ctx) {
|
||||
export type ContactCardProps = {
|
||||
tel?: string;
|
||||
name?: string;
|
||||
type?: string;
|
||||
addText?: string;
|
||||
editable?: boolean;
|
||||
};
|
||||
|
||||
function ContactCard(
|
||||
h: CreateElement,
|
||||
props: ContactCardProps,
|
||||
slots: DefaultSlots,
|
||||
ctx: RenderContext<ContactCardProps>
|
||||
) {
|
||||
const { type, editable } = props;
|
||||
|
||||
return (
|
||||
@@ -15,7 +32,7 @@ function ContactCard(h, props, slots, ctx) {
|
||||
class={bem([type])}
|
||||
valueClass={bem('value')}
|
||||
icon={type === 'edit' ? 'contact' : 'add-square'}
|
||||
onClick={event => {
|
||||
onClick={(event: Event) => {
|
||||
if (editable) {
|
||||
emit(ctx, 'click', event);
|
||||
}
|
||||
@@ -46,4 +63,4 @@ ContactCard.props = {
|
||||
}
|
||||
};
|
||||
|
||||
export default sfc(ContactCard);
|
||||
export default sfc<ContactCardProps>(ContactCard);
|
||||
Reference in New Issue
Block a user