UNPKG

@tarojs/components

Version:
31 lines (27 loc) 913 B
import { r as registerInstance, c as createEvent, h } from './index-5e431bb8.js'; const indexCss = "taro-cover-image-core{width:320px;height:240px;overflow:hidden}"; const CoverImage = class { constructor(hostRef) { registerInstance(this, hostRef); this.onLoad = createEvent(this, "load", 7); this.onError = createEvent(this, "error", 7); this.src = undefined; this.nativeProps = {}; } imageOnLoad() { const { width, height, } = this.imgRef; this.onLoad.emit({ width, height }); } imageOnError(e) { this.onError.emit(e); } render() { const { src, imageOnLoad, imageOnError, nativeProps } = this; return (h("img", Object.assign({ ref: img => (this.imgRef = img), src: src, onLoad: imageOnLoad.bind(this), onError: imageOnError.bind(this) }, nativeProps))); } }; CoverImage.style = indexCss; export { CoverImage as taro_cover_image_core };