<template>
  <component ref="component" :is="component"/>
</template>

<script>
import ArticleInput from './ArticleInput'
import MultipleResourceGroupInput from './MultipleResourceGroupInput'
import CategoryInput from './CategoryInput'
import MultipleCategoryInput from './MultipleCategoryInput'
import TextInput from './TextInput'
import NumberInput from './NumberInput'
export default {
  name: 'TemplateParameterInput',
  components: {
    ArticleInput,
    MultipleResourceGroupInput,
    CategoryInput,
    MultipleCategoryInput,
    TextInput,
    NumberInput,
  },
  props: {
    // 资源类型
    type: {
      required: true
    }
  },
  computed: {
    component () {
      let targetComponent = this.$options.components[this.type]
      if (targetComponent == null) {
        throw new Error(`未能匹配参数输入类型 ${this.type}`)
      }
      return targetComponent
    }
  }
}
</script>
