【发布时间】:2019-12-31 08:08:57
【问题描述】:
我有一个支持function 或Component 的道具。所以我想通过检查道具的类型来区分它是组件还是函数。我目前正在使用以下一个。当代码被混淆时,这可能在 prod 中不起作用。想知道更好的解决方案吗?
let isSvelteComponent = component => {
return (
typeof component !== "undefined" &&
component.__proto__.name === "SvelteComponentDev"
);
};
【问题讨论】:
标签: svelte svelte-3 svelte-component