const handleOperation = (icon: string) => {
const handleSetting = () => {
console.log("handleSetting");
};
const handleDataAnalysis = () => {
console.log("handleDataAnalysis");
};
const handlers: { [key: string]: () => void } = {
"Setting": handleSetting,
"DataAnalysis": handleDataAnalysis
};
const handler = handlers[icon];
handler ? handler() : (() => {
throw new Error("No handler found for icon: " + icon);
})();
};
vue3 ts 不使用 if switch 来决定使用什么函数
最新推荐文章于 2024-12-15 10:15:00 发布
3943

被折叠的 条评论
为什么被折叠?



