mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 18:54:24 +00:00
[improvement] AddressList: jsx (#2504)
This commit is contained in:
47
packages/address-list/Item.js
Normal file
47
packages/address-list/Item.js
Normal file
@@ -0,0 +1,47 @@
|
||||
import { use } from '../utils';
|
||||
import Icon from '../icon';
|
||||
import Cell from '../cell';
|
||||
import Radio from '../radio';
|
||||
|
||||
const [sfc, bem] = use('address-item');
|
||||
|
||||
export default sfc({
|
||||
props: {
|
||||
data: Object,
|
||||
disabled: Boolean,
|
||||
switchable: Boolean
|
||||
},
|
||||
|
||||
methods: {
|
||||
onSelect() {
|
||||
if (this.switchable) {
|
||||
this.$emit('select');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
render(h) {
|
||||
const { data, disabled, switchable } = this;
|
||||
return (
|
||||
<Cell
|
||||
class={bem({ disabled, unswitchable: !switchable })}
|
||||
is-link={!disabled && switchable}
|
||||
onClick={this.onSelect}
|
||||
>
|
||||
<Radio name={data.id}>
|
||||
<div class={bem('name')}>{`${data.name},${data.tel}`}</div>
|
||||
<div class={bem('address')}>{data.address}</div>
|
||||
</Radio>
|
||||
<Icon
|
||||
slot="right-icon"
|
||||
name="edit"
|
||||
class={bem('edit')}
|
||||
onClick={event => {
|
||||
event.stopPropagation();
|
||||
this.$emit('edit');
|
||||
}}
|
||||
/>
|
||||
</Cell>
|
||||
);
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user