import { use } from '../../utils'; import Icon from '../../icon'; import Loading from '../../loading'; import Uploader from '../../uploader'; const [sfc, bem] = use('sku-img-uploader'); export default sfc({ props: { value: String, uploadImg: Function, maxSize: { type: Number, default: 6 } }, data() { return { // 正在上传的图片 base64 paddingImg: '' }; }, computed: { imgList() { return this.value && !this.paddingImg ? [this.value] : []; } }, methods: { afterReadFile(file) { // 上传文件 this.paddingImg = file.content; this.uploadImg(file.file, file.content) .then(img => { this.$emit('input', img); this.$nextTick(() => { this.paddingImg = ''; }); }) .catch(() => { this.paddingImg = ''; }); }, onOversize() { this.$toast(`最大可上传图片为${this.maxSize}MB,请尝试压缩图片尺寸`); } }, render(h) { const { imgList, paddingImg } = this; const ImageList = (paddingImg || imgList.length > 0) && (