mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-24 23:49:14 +08:00
[improvement] ContactCard: jsx (#2506)
This commit is contained in:
parent
b5d1d00db5
commit
7c0afd874b
@ -257,9 +257,9 @@ export default sfc({
|
|||||||
focused={this.detailFocused}
|
focused={this.detailFocused}
|
||||||
value={data.addressDetail}
|
value={data.addressDetail}
|
||||||
error={errorInfo.addressDetail}
|
error={errorInfo.addressDetail}
|
||||||
detail-rows={this.detailRows}
|
detailRows={this.detailRows}
|
||||||
search-result={this.searchResult}
|
searchResult={this.searchResult}
|
||||||
show-search-result={this.showSearchResult}
|
showSearchResult={this.showSearchResult}
|
||||||
onFocus={onFocus('addressDetail')}
|
onFocus={onFocus('addressDetail')}
|
||||||
onBlur={() => {
|
onBlur={() => {
|
||||||
this.detailFocused = false;
|
this.detailFocused = false;
|
||||||
@ -312,14 +312,14 @@ export default sfc({
|
|||||||
<Popup
|
<Popup
|
||||||
v-model={this.showAreaPopup}
|
v-model={this.showAreaPopup}
|
||||||
position="bottom"
|
position="bottom"
|
||||||
lazy-render={false}
|
lazyRender={false}
|
||||||
get-container="body"
|
getContainer="body"
|
||||||
>
|
>
|
||||||
<Area
|
<Area
|
||||||
ref="area"
|
ref="area"
|
||||||
loading={!this.areaListLoaded}
|
loading={!this.areaListLoaded}
|
||||||
value={data.areaCode}
|
value={data.areaCode}
|
||||||
area-list={this.areaList}
|
areaList={this.areaList}
|
||||||
onConfirm={this.onAreaConfirm}
|
onConfirm={this.onAreaConfirm}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
this.showAreaPopup = false;
|
this.showAreaPopup = false;
|
||||||
|
@ -190,13 +190,13 @@ export default sfc({
|
|||||||
<Picker
|
<Picker
|
||||||
ref="picker"
|
ref="picker"
|
||||||
class={bem()}
|
class={bem()}
|
||||||
show-toolbar
|
showToolbar
|
||||||
value-key="name"
|
valueKey="name"
|
||||||
title={this.title}
|
title={this.title}
|
||||||
loading={this.loading}
|
loading={this.loading}
|
||||||
columns={this.displayColumns}
|
columns={this.displayColumns}
|
||||||
item-height={this.itemHeight}
|
itemHeight={this.itemHeight}
|
||||||
visible-item-count={this.visibleItemCount}
|
visibleItemCount={this.visibleItemCount}
|
||||||
{...{ on: this.listeners }}
|
{...{ on: this.listeners }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
46
packages/contact-card/index.js
Normal file
46
packages/contact-card/index.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import { use } from '../utils';
|
||||||
|
import Cell from '../cell';
|
||||||
|
|
||||||
|
const [sfc, bem, t] = use('contact-card');
|
||||||
|
|
||||||
|
export default sfc({
|
||||||
|
props: {
|
||||||
|
tel: String,
|
||||||
|
name: String,
|
||||||
|
addText: String,
|
||||||
|
editable: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
type: String,
|
||||||
|
default: 'add'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
onClick(event) {
|
||||||
|
if (this.editable) {
|
||||||
|
this.$emit('click', event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
render(h) {
|
||||||
|
const { type } = this;
|
||||||
|
return (
|
||||||
|
<Cell
|
||||||
|
center
|
||||||
|
border={false}
|
||||||
|
class={bem([type])}
|
||||||
|
isLink={this.editable}
|
||||||
|
icon={type === 'edit' ? 'contact' : 'add-square'}
|
||||||
|
onClick={this.onClick}
|
||||||
|
>
|
||||||
|
{type === 'add'
|
||||||
|
? this.addText || t('addText')
|
||||||
|
: [<div>{`${t('name')}:${this.name}`}</div>, <div>{`${t('tel')}:${this.tel}`}</div>]}
|
||||||
|
</Cell>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
@ -1,46 +0,0 @@
|
|||||||
<template>
|
|
||||||
<cell
|
|
||||||
center
|
|
||||||
:border="false"
|
|
||||||
:class="b([type])"
|
|
||||||
:is-link="editable"
|
|
||||||
:icon="type === 'edit' ? 'contact' : 'add-square'"
|
|
||||||
@click="onClick"
|
|
||||||
>
|
|
||||||
<template v-if="type === 'add'">{{ addText || $t('addText') }}</template>
|
|
||||||
<template v-else>
|
|
||||||
<div>{{ $t('name') }}:{{ name }}</div>
|
|
||||||
<div>{{ $t('tel') }}:{{ tel }}</div>
|
|
||||||
</template>
|
|
||||||
</cell>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import create from '../utils/create';
|
|
||||||
|
|
||||||
export default create({
|
|
||||||
name: 'contact-card',
|
|
||||||
|
|
||||||
props: {
|
|
||||||
tel: String,
|
|
||||||
name: String,
|
|
||||||
addText: String,
|
|
||||||
editable: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
},
|
|
||||||
type: {
|
|
||||||
type: String,
|
|
||||||
default: 'add'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
onClick(event) {
|
|
||||||
if (this.editable) {
|
|
||||||
this.$emit('click', event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
Loading…
x
Reference in New Issue
Block a user