types(ContactEdit): use tsx (#8145)

* types(ContactEdit): use tsx

* types: improve
This commit is contained in:
neverland 2021-02-12 20:18:30 +08:00 committed by GitHub
parent cb2c2b9b68
commit 4f4e0b4f94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
import { watch, reactive } from 'vue'; import { watch, reactive, PropType } from 'vue';
// Utils // Utils
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
@ -14,7 +14,13 @@ import Switch from '../switch';
const [createComponent, bem, t] = createNamespace('contact-edit'); const [createComponent, bem, t] = createNamespace('contact-edit');
const DEFAULT_CONTACT = { export type ContactInfo = {
tel: string;
name: string;
isDefault?: boolean;
};
const DEFAULT_CONTACT: ContactInfo = {
tel: '', tel: '',
name: '', name: '',
}; };
@ -27,11 +33,11 @@ export default createComponent({
showSetDefault: Boolean, showSetDefault: Boolean,
setDefaultLabel: String, setDefaultLabel: String,
contactInfo: { contactInfo: {
type: Object, type: Object as PropType<ContactInfo>,
default: () => ({ ...DEFAULT_CONTACT }), default: () => ({ ...DEFAULT_CONTACT }),
}, },
telValidator: { telValidator: {
type: Function, type: Function as PropType<(val: string) => boolean>,
default: isMobile, default: isMobile,
}, },
}, },
@ -84,8 +90,8 @@ export default createComponent({
<Switch <Switch
v-model={contact.isDefault} v-model={contact.isDefault}
size={24} size={24}
onChange={(event) => { onChange={(checked: boolean) => {
emit('change-default', event); emit('change-default', checked);
}} }}
/> />
); );