You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.1 KiB

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _utils = require("../utils");
var _Network = _interopRequireDefault(require("./Network"));
var _createNamespace = (0, _utils.createNamespace)('empty'),
createComponent = _createNamespace[0],
bem = _createNamespace[1];
var PRESETS = ['error', 'search', 'default'];
var _default = createComponent({
props: {
imageSize: [Number, String],
description: String,
image: {
type: String,
default: 'default'
}
},
methods: {
genImageContent: function genImageContent() {
var h = this.$createElement;
var slots = this.slots('image');
if (slots) {
return slots;
}
if (this.image === 'network') {
return h(_Network.default);
}
var image = this.image;
if (PRESETS.indexOf(image) !== -1) {
image = "https://img.yzcdn.cn/vant/empty-image-" + image + ".png";
}
return h("img", {
"attrs": {
"src": image
}
});
},
genImage: function genImage() {
var h = this.$createElement;
var imageStyle = {
width: (0, _utils.addUnit)(this.imageSize),
height: (0, _utils.addUnit)(this.imageSize)
};
return h("div", {
"class": bem('image'),
"style": imageStyle
}, [this.genImageContent()]);
},
genDescription: function genDescription() {
var h = this.$createElement;
var description = this.slots('description') || this.description;
if (description) {
return h("p", {
"class": bem('description')
}, [description]);
}
},
genBottom: function genBottom() {
var h = this.$createElement;
var slot = this.slots();
if (slot) {
return h("div", {
"class": bem('bottom')
}, [slot]);
}
}
},
render: function render() {
var h = arguments[0];
return h("div", {
"class": bem()
}, [this.genImage(), this.genDescription(), this.genBottom()]);
}
});
exports.default = _default;