forked from fdzcxy212206413/gsl_grs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
597 B
28 lines
597 B
1 month ago
|
import { provide } from 'vue';
|
||
|
|
||
|
const FORWARD_REF_INJECTION_KEY = Symbol("elForwardRef");
|
||
|
const useForwardRef = (forwardRef) => {
|
||
|
const setForwardRef = (el) => {
|
||
|
forwardRef.value = el;
|
||
|
};
|
||
|
provide(FORWARD_REF_INJECTION_KEY, {
|
||
|
setForwardRef
|
||
|
});
|
||
|
};
|
||
|
const useForwardRefDirective = (setForwardRef) => {
|
||
|
return {
|
||
|
mounted(el) {
|
||
|
setForwardRef(el);
|
||
|
},
|
||
|
updated(el) {
|
||
|
setForwardRef(el);
|
||
|
},
|
||
|
unmounted() {
|
||
|
setForwardRef(null);
|
||
|
}
|
||
|
};
|
||
|
};
|
||
|
|
||
|
export { FORWARD_REF_INJECTION_KEY, useForwardRef, useForwardRefDirective };
|
||
|
//# sourceMappingURL=index.mjs.map
|