feat(AddressEdit): refactor style (#5117)

This commit is contained in:
rex
2019-11-26 20:44:15 +08:00
committed by neverland
parent 68fef3d72a
commit c58f8e54ba
6 changed files with 329 additions and 248 deletions
+22 -4
View File
@@ -17,6 +17,12 @@ export default createComponent({
showSearchResult: Boolean
},
computed: {
shouldShowSearchResult() {
return this.focused && this.searchResult && this.showSearchResult;
}
},
methods: {
onSelect(express) {
this.$emit('select-search', express);
@@ -42,19 +48,30 @@ export default createComponent({
},
genSearchResult() {
const { searchResult } = this;
const show = this.focused && searchResult && this.showSearchResult;
if (show) {
const { value, shouldShowSearchResult, searchResult } = this;
if (shouldShowSearchResult) {
return searchResult.map(express => (
<Cell
key={express.name + express.address}
title={express.name}
class={bem('search-item')}
label={express.address}
border={false}
icon="location-o"
clickable
onClick={() => {
this.onSelect(express);
}}
scopedSlots={{
title: () =>
express.name && (
<div
domPropsInnerHTML={express.name.replace(
value,
`<span class=${bem('keyword')}>${value}</span>`
)}
/>
)
}}
/>
));
}
@@ -72,6 +89,7 @@ export default createComponent({
type="textarea"
value={this.value}
error={this.error}
border={!this.shouldShowSearchResult}
label={t('label')}
maxlength={this.detailMaxlength}
placeholder={t('placeholder')}