diff --git a/src/contact-list/index.js b/src/contact-list/index.js index 7dcf1a929..5fbbdf688 100644 --- a/src/contact-list/index.js +++ b/src/contact-list/index.js @@ -23,89 +23,76 @@ export default createComponent({ emits: ['add', 'edit', 'select', 'update:modelValue'], setup(props, { emit }) { - return () => { - const List = - props.list && - props.list.map((item, index) => { - function onClick() { - emit('update:modelValue', item.id); - emit('select', item, index); - } + const renderItem = (item, index) => { + const onClick = () => { + emit('update:modelValue', item.id); + emit('select', item, index); + }; - function RightIcon() { - return ( - - ); - } + const renderRightIcon = () => ( + + ); - function LeftIcon() { - return ( - { - event.stopPropagation(); - emit('edit', item, index); - }} - /> - ); - } + const renderLeftIcon = () => ( + { + event.stopPropagation(); + emit('edit', item, index); + }} + /> + ); - function Content() { - const nodes = [`${item.name},${item.tel}`]; + const renderContent = () => { + const nodes = [`${item.name},${item.tel}`]; - if (item.isDefault && props.defaultTagText) { - nodes.push( - - {props.defaultTagText} - - ); - } - - return nodes; - } - - return ( - + if (item.isDefault && props.defaultTagText) { + nodes.push( + + {props.defaultTagText} + ); - }); + } + + return nodes; + }; return ( - - - {List} - - - { - emit('add'); - }} - /> - - + ); }; + + return () => ( + + + {props.list && props.list.map(renderItem)} + + + { + emit('add'); + }} + /> + + + ); }, });