mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-23 06:59:15 +08:00
fix(ContactList): select event triggered twice
This commit is contained in:
parent
6d483a8da5
commit
1dd4083102
@ -23,89 +23,76 @@ export default createComponent({
|
|||||||
emits: ['add', 'edit', 'select', 'update:modelValue'],
|
emits: ['add', 'edit', 'select', 'update:modelValue'],
|
||||||
|
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
return () => {
|
const renderItem = (item, index) => {
|
||||||
const List =
|
const onClick = () => {
|
||||||
props.list &&
|
emit('update:modelValue', item.id);
|
||||||
props.list.map((item, index) => {
|
emit('select', item, index);
|
||||||
function onClick() {
|
};
|
||||||
emit('update:modelValue', item.id);
|
|
||||||
emit('select', item, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
function RightIcon() {
|
const renderRightIcon = () => (
|
||||||
return (
|
<Radio name={item.id} iconSize={16} checkedColor={RED} />
|
||||||
<Radio
|
);
|
||||||
name={item.id}
|
|
||||||
iconSize={16}
|
|
||||||
checkedColor={RED}
|
|
||||||
onClick={onClick}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function LeftIcon() {
|
const renderLeftIcon = () => (
|
||||||
return (
|
<Icon
|
||||||
<Icon
|
name="edit"
|
||||||
name="edit"
|
class={bem('edit')}
|
||||||
class={bem('edit')}
|
onClick={(event) => {
|
||||||
onClick={(event) => {
|
event.stopPropagation();
|
||||||
event.stopPropagation();
|
emit('edit', item, index);
|
||||||
emit('edit', item, index);
|
}}
|
||||||
}}
|
/>
|
||||||
/>
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function Content() {
|
const renderContent = () => {
|
||||||
const nodes = [`${item.name},${item.tel}`];
|
const nodes = [`${item.name},${item.tel}`];
|
||||||
|
|
||||||
if (item.isDefault && props.defaultTagText) {
|
if (item.isDefault && props.defaultTagText) {
|
||||||
nodes.push(
|
nodes.push(
|
||||||
<Tag type="danger" round class={bem('item-tag')}>
|
<Tag type="danger" round class={bem('item-tag')}>
|
||||||
{props.defaultTagText}
|
{props.defaultTagText}
|
||||||
</Tag>
|
</Tag>
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return nodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Cell
|
|
||||||
v-slots={{
|
|
||||||
icon: LeftIcon,
|
|
||||||
default: Content,
|
|
||||||
'right-icon': RightIcon,
|
|
||||||
}}
|
|
||||||
key={item.id}
|
|
||||||
isLink
|
|
||||||
center
|
|
||||||
class={bem('item')}
|
|
||||||
valueClass={bem('item-value')}
|
|
||||||
onClick={onClick}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
return nodes;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class={bem()}>
|
<Cell
|
||||||
<RadioGroup modelValue={props.modelValue} class={bem('group')}>
|
v-slots={{
|
||||||
{List}
|
icon: renderLeftIcon,
|
||||||
</RadioGroup>
|
default: renderContent,
|
||||||
<div class={bem('bottom')}>
|
'right-icon': renderRightIcon,
|
||||||
<Button
|
}}
|
||||||
round
|
key={item.id}
|
||||||
block
|
isLink
|
||||||
type="danger"
|
center
|
||||||
class={bem('add')}
|
class={bem('item')}
|
||||||
text={props.addText || t('addText')}
|
valueClass={bem('item-value')}
|
||||||
onClick={() => {
|
onClick={onClick}
|
||||||
emit('add');
|
/>
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return () => (
|
||||||
|
<div class={bem()}>
|
||||||
|
<RadioGroup modelValue={props.modelValue} class={bem('group')}>
|
||||||
|
{props.list && props.list.map(renderItem)}
|
||||||
|
</RadioGroup>
|
||||||
|
<div class={bem('bottom')}>
|
||||||
|
<Button
|
||||||
|
round
|
||||||
|
block
|
||||||
|
type="danger"
|
||||||
|
class={bem('add')}
|
||||||
|
text={props.addText || t('addText')}
|
||||||
|
onClick={() => {
|
||||||
|
emit('add');
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user