use-proxy.js 555 B

123456789101112131415161718192021222324
  1. import { computed } from 'vue'
  2. import { getFieldValue, getUsingConfig } from '@cip/utils/util'
  3. export const useProxy = (props, keys, emit) => {
  4. return [].concat(keys).map(key => {
  5. return computed({
  6. get () {
  7. return getFieldValue(props, key)
  8. },
  9. set (val) {
  10. emit(`update:${key}`, val)
  11. }
  12. })
  13. })
  14. }
  15. export const useDisabled = (props, keys) => {
  16. return []
  17. .concat(keys)
  18. .map(key =>
  19. computed(() =>
  20. getUsingConfig(props.disabled, getFieldValue(props.disabledConfig, key))
  21. )
  22. )
  23. }