How to dynamically import svg file?
I'm trying to do dynamic import svg file based on user select, such as:
```
import { onMount } from "solid-js";
export const DynaSvg = (props) => {
let SvgComp;
onMount(async () => {
SvgComp = await import(`./${props.name}.svg`);
console.log(SvgComp);
// SvgComp.ref = props.parentRef;
});
return (
<Show when={SvgComp}>
<div>
<SvgComp />
</div>
</Show>
)
};
```
But it doesn't work, is there anyway to do this?
4 条评论