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

    //详细：dom输出值
    let drawText = createElement(`span`, {}, [this.$attrs.value ? '是' : '否'])

    //编辑：dom表单元素
    let drawFromComponents = createElement(
      // 标签名称
      `vxe-switch`,
      // 传递数据
      {
        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>