feat(Empty): support offline scenario (#6055)

This commit is contained in:
neverland
2020-04-15 14:08:07 +08:00
committed by GitHub
parent 43777e7da9
commit 455be42c11
5 changed files with 298 additions and 59 deletions
+20 -10
View File
@@ -1,8 +1,9 @@
import { createNamespace } from '../utils';
import Network from './Network';
const [createComponent, bem] = createNamespace('empty');
const PRESETS = ['error', 'search', 'default', 'network'];
const PRESETS = ['error', 'search', 'default'];
export default createComponent({
props: {
@@ -13,20 +14,29 @@ export default createComponent({
},
},
computed: {
url() {
if (PRESETS.indexOf(this.image) !== -1) {
return `https://img.yzcdn.cn/vant/empty-image-${this.image}.png`;
methods: {
genImageContent() {
const slots = this.slots('image');
if (slots) {
return slots;
}
return this.image;
if (this.image === 'network') {
return <Network />;
}
let { image } = this;
if (PRESETS.indexOf(image) !== -1) {
image = `https://img.yzcdn.cn/vant/empty-image-${image}.png`;
}
return <img src={image} />;
},
},
methods: {
genImage() {
const image = this.slots('image') || <img src={this.url} />;
return <div class={bem('image')}>{image}</div>;
return <div class={bem('image')}>{this.genImageContent()}</div>;
},
genDescription() {