首页 > 解决方案 > 当`customElement:true`时如何使用`svelte-spa-router`?

问题描述

我这样使用它:

<script>
import Router from "svelte-spa-router";
</script>
<Router routes={{}} />

我得到了一些编译时警告和运行时错误:

编译时警告

运行时错误

啊,而且,当我尝试使用其他没有<svelte:options tag="xxx" />标记的组件时,我也收到了警告/错误。

又怎样?

标签: componentssveltecustom-element

解决方案


  1. 您应该将标签设置为“xxx-yyy”;
  2. 在 vite 或汇总配置中设置 svelte({ compilerOptions: { customElement: true }})

推荐阅读