Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

Import Svelte component from a path which is set in string variable

$
0
0

I am trying to import Svelte component from path which is set in string variable.

When I import the component using directly, it is working:

import("./Component.svelte").then(module => {    Component2 = module.default;}).catch(error => {});

But, when I try to define a variable with the path of component and import it, it doesn't:

let filePath = "./Component.svelte"import(filePath).then(module => {  Component2 = module.default;}).catch(error => {});

Is there anyway that I can import component with variable source path?

Here is the REPL


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>