【发布时间】:2020-12-20 07:03:55
【问题描述】:
我想动态插入组件。但是,它失败了。有人能告诉我这件事和解决这个问题的建议吗? REPL 在这里。
<script>
let Chatbox;
function loadChatbox() {
// this is available.
// import('./ChatBox.svelte').then(res => Chatbox = res.default)
// but, this is not. Why?? and How to make it??
const name = './ChatBox.svelte';
import(name).then(res => Chatbox = res.default)
}
</script>
<button on:click="{loadChatbox}">Load chatbox</button>
<svelte:component this="{Chatbox}" />
【问题讨论】:
标签: javascript svelte