/** * 表单域 */ import template from "./FormItem.html"; class FormItem { require = ["^?antdForm"]; context = true; state = { labelCol: null, wrapperCol: null, }; constructor($element, $attrs, $controllers) { let [antdForm] = $controllers; if (antdForm) { this.antdForm = antdForm.getContext(); } if (this.props.labelCol && this.props.labelCol.span) { this.state.labelCol = this.props.labelCol.span; } else if ( this.antdForm.labelCol && this.antdForm.labelCol.span ) { this.state.labelCol = this.antdForm.labelCol.span; } if (this.props.wrapperCol && this.props.wrapperCol.span) { this.state.wrapperCol = this.props.wrapperCol.span; } else if ( this.antdForm.wrapperCol && this.antdForm.wrapperCol.span ) { this.state.wrapperCol = this.antdForm.wrapperCol.span; } } render() { return template; } } FormItem.propTypes = { name: PropTypes.string, label: PropTypes.string, labelCol: PropTypes.object, wrapperCol: PropTypes.object, required: PropTypes.boolean, };