@arco-design/web-vue
Version:
Arco Design Vue 2.0: A Vue.js 3 UI Library
16 lines (15 loc) • 444 B
JavaScript
import { getCurrentInstance, ref, onUpdated } from "vue";
import { generateKey } from "../utils/tree-data.js";
function useNodeKey() {
const instance = getCurrentInstance();
const getKey = () => {
var _a;
return (_a = instance == null ? void 0 : instance.vnode.key) != null ? _a : generateKey();
};
const key = ref(getKey());
onUpdated(() => {
key.value = getKey();
});
return key;
}
export { useNodeKey as default };