mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(AddressList): add event param for click-item (#12748)
This commit is contained in:
parent
60a0ac146a
commit
b332c1643a
@ -54,7 +54,8 @@ export default defineComponent({
|
|||||||
const onEdit = () =>
|
const onEdit = () =>
|
||||||
emit(disabled ? 'editDisabled' : 'edit', item, index);
|
emit(disabled ? 'editDisabled' : 'edit', item, index);
|
||||||
|
|
||||||
const onClick = () => emit('clickItem', item, index);
|
const onClick = (event: MouseEvent) =>
|
||||||
|
emit('clickItem', item, index, { event });
|
||||||
|
|
||||||
const onSelect = () => {
|
const onSelect = () => {
|
||||||
emit(disabled ? 'selectDisabled' : 'select', item, index);
|
emit(disabled ? 'selectDisabled' : 'select', item, index);
|
||||||
|
@ -39,11 +39,11 @@ export default defineComponent({
|
|||||||
emits: ['edit', 'click', 'select'],
|
emits: ['edit', 'click', 'select'],
|
||||||
|
|
||||||
setup(props, { slots, emit }) {
|
setup(props, { slots, emit }) {
|
||||||
const onClick = () => {
|
const onClick = (event: MouseEvent) => {
|
||||||
if (props.switchable) {
|
if (props.switchable) {
|
||||||
emit('select');
|
emit('select');
|
||||||
}
|
}
|
||||||
emit('click');
|
emit('click', event);
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderRightIcon = () => (
|
const renderRightIcon = () => (
|
||||||
@ -53,7 +53,7 @@ export default defineComponent({
|
|||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
emit('edit');
|
emit('edit');
|
||||||
emit('click');
|
emit('click', event);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -102,7 +102,7 @@ export default {
|
|||||||
| select | Emitted when an address is selected | _item: Address, index: number_ |
|
| select | Emitted when an address is selected | _item: Address, index: number_ |
|
||||||
| edit-disabled | Emitted when the edit icon of disabled address is clicked | _item: Address, index: number_ |
|
| edit-disabled | Emitted when the edit icon of disabled address is clicked | _item: Address, index: number_ |
|
||||||
| select-disabled | Emitted when a disabled address is selected | _item: Address, index: number_ |
|
| select-disabled | Emitted when a disabled address is selected | _item: Address, index: number_ |
|
||||||
| click-item | Emitted when an address item is clicked | _item: Address, index: number_ |
|
| click-item | Emitted when an address item is clicked | _item: Address, index: number, { event }_ |
|
||||||
|
|
||||||
### Data Structure of Address
|
### Data Structure of Address
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ export default {
|
|||||||
| select | 切换选中的地址时触发 | _item: AddressListAddress, index: number_ |
|
| select | 切换选中的地址时触发 | _item: AddressListAddress, index: number_ |
|
||||||
| edit-disabled | 编辑不可配送的地址时触发 | _item: AddressListAddress, index: number_ |
|
| edit-disabled | 编辑不可配送的地址时触发 | _item: AddressListAddress, index: number_ |
|
||||||
| select-disabled | 选中不可配送的地址时触发 | _item: AddressListAddress, index: number_ |
|
| select-disabled | 选中不可配送的地址时触发 | _item: AddressListAddress, index: number_ |
|
||||||
| click-item | 点击任意地址时触发 | _item: AddressListAddress, index: number_ |
|
| click-item | 点击任意地址时触发 | _item: AddressListAddress, index: number, { event }_ |
|
||||||
|
|
||||||
### AddressListAddress 数据结构
|
### AddressListAddress 数据结构
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ test('should emit clickItem event when item is clicked', () => {
|
|||||||
|
|
||||||
wrapper.find('.van-address-item').trigger('click');
|
wrapper.find('.van-address-item').trigger('click');
|
||||||
|
|
||||||
expect(wrapper.emitted('clickItem')![0]).toEqual([list[0], 0]);
|
expect(wrapper.emitted('clickItem')![0].slice(0, 2)).toEqual([list[0], 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should render tag slot correctly', () => {
|
test('should render tag slot correctly', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user