我创建了一个钩子函数并想在其他地方重用它:
\nimport { ref, Ref, reactive } from 'vue'\n\nconst useSelectAarray = <T>(items: T[]) => {\n const selectItem: Ref<T|null> = ref(null)\n const options = reactive([...items])\n const select = (key: string, value: any) => {\n const trigger = options.find((item: { [index: string]: any }) => item[key] === value)\n\n if (typeof trigger !== 'undefined') {\n selectItem.value = trigger\n }\n }\n\n return { \n selectItem,\n select,\n items: options\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n但是在selectItem.value = trigger,我收到类型错误Type 'UnwrapRefSimple<T>' is not assignable to type 'T'\xe3\x80\x82 …