optgroup.js 865 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { createOption, destroyOption, assemOption } from './util'
  2. const props = {
  3. label: { type: [String, Number, Boolean], default: '' },
  4. visible: { type: Boolean, default: null },
  5. disabled: Boolean
  6. }
  7. const watch = {}
  8. Object.keys(props).forEach(name => {
  9. watch[name] = function (value) {
  10. this.optionConfig.update(name, value)
  11. }
  12. })
  13. export default {
  14. name: 'VxeOptgroup',
  15. props,
  16. provide () {
  17. return {
  18. $xeoptgroup: this
  19. }
  20. },
  21. inject: {
  22. $xeselect: {
  23. default: null
  24. }
  25. },
  26. computed: {
  27. vSize () {
  28. return this.size || this.$parent.size || this.$parent.vSize
  29. }
  30. },
  31. watch,
  32. mounted () {
  33. assemOption(this)
  34. },
  35. created () {
  36. this.optionConfig = createOption(this.$xeselect, this)
  37. },
  38. destroyed () {
  39. destroyOption(this)
  40. },
  41. render (h) {
  42. return h('div', this.$slots.default)
  43. }
  44. }