import { reactive, toRefs } from "vue";

/**
 * @description dynamicRefs 动态绑定 ref 的封装
 * */
export const useDynameicRef = () => {
  const state = reactive<any>({
    dynamicRefs: []
  });

  // 动态绑定 ref 的方法
  const setDynamicRef = (el, refName) => {
    if (el) {
      state.dynamicRefs[refName] = el;
    }
  };

  return {
    ...toRefs(state),
    setDynamicRef
  };
};
