mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
types(ContactList): use tsx (#8146)
This commit is contained in:
parent
4f4e0b4f94
commit
7ec644c3bc
@ -1,3 +1,5 @@
|
|||||||
|
import { PropType } from 'vue';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { createNamespace } from '../utils';
|
import { createNamespace } from '../utils';
|
||||||
import { RED } from '../utils/constant';
|
import { RED } from '../utils/constant';
|
||||||
@ -12,18 +14,25 @@ import RadioGroup from '../radio-group';
|
|||||||
|
|
||||||
const [createComponent, bem, t] = createNamespace('contact-list');
|
const [createComponent, bem, t] = createNamespace('contact-list');
|
||||||
|
|
||||||
|
export type ContactListItem = {
|
||||||
|
id?: number | string;
|
||||||
|
tel: number | string;
|
||||||
|
name: string;
|
||||||
|
isDefault?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
export default createComponent({
|
export default createComponent({
|
||||||
props: {
|
props: {
|
||||||
list: Array,
|
list: Array as PropType<ContactListItem[]>,
|
||||||
addText: String,
|
addText: String,
|
||||||
modelValue: null,
|
modelValue: null as any,
|
||||||
defaultTagText: String,
|
defaultTagText: String,
|
||||||
},
|
},
|
||||||
|
|
||||||
emits: ['add', 'edit', 'select', 'update:modelValue'],
|
emits: ['add', 'edit', 'select', 'update:modelValue'],
|
||||||
|
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const renderItem = (item, index) => {
|
const renderItem = (item: ContactListItem, index: number) => {
|
||||||
const onClick = () => {
|
const onClick = () => {
|
||||||
emit('update:modelValue', item.id);
|
emit('update:modelValue', item.id);
|
||||||
emit('select', item, index);
|
emit('select', item, index);
|
||||||
@ -45,7 +54,7 @@ export default createComponent({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const renderContent = () => {
|
const renderContent = () => {
|
||||||
const nodes = [`${item.name},${item.tel}`];
|
const nodes: JSX.Element[] = [`${item.name},${item.tel}`];
|
||||||
|
|
||||||
if (item.isDefault && props.defaultTagText) {
|
if (item.isDefault && props.defaultTagText) {
|
||||||
nodes.push(
|
nodes.push(
|
Loading…
x
Reference in New Issue
Block a user