<!--
 * @Descripttion:
 * @Version: 1.0
 * @Author: +C
 * @Date: 2022-02-15 08:47:06
 * @LastEditors: wufz
 * @LastEditTime: 2022-02-23 11:49:16
-->
<script>
import formComponents from "./formComponents"
export default {
  name: `DxxTextarea`,
  //继承表单父组件
  extends: formComponents,
  // functional: true, //函数式组件
  props: [],
  //建立虚拟 DOM
  render(createElement) {
    // let _this = Object.entries(this)

    let maxHeight = this.$attrs['max-height']
    //详细：dom输出值
    let isObject = Object.prototype.toString.call(this.$attrs.value) === '[object Object]'
    let detailStyle = {}
    if (maxHeight && this.isDetail) {
      detailStyle.maxHeight = maxHeight + 'px'
      detailStyle.overflow = 'auto'
    }
    let drawText = createElement(`div`, detailStyle, [isObject ? this.$attrs.value.value : this.$attrs.value])

    //编辑：dom表单元素
    let drawFromComponents = createElement(
      // 标签名称
      `vxe-textarea`,
      // 传递数据
      {
        attrs: {
          ...this.$attrs
        },
        on: {
          ...this.$listeners
        }
        /* ...context.data,
        props: {
          ...context.props
        },
        class: (context.data.staticClass || "") + "", //自定义class
        style: {
          ...context.data.staticStyle
        } */
      },
      // 子节点数组，createElement...
      [
        this.$slots.default
      ]
    );

    return this.isDetail ? drawText : drawFromComponents;
  }
};
</script>

<style scoped>
</style>