我在斯维特用tw in js/twind。当使用Svelte应用程序的普通安装程序时,在包含Twind之后,我找不到任何方法让插件工作:
<script>
import {tw, apply, setup} from 'twind/css';
setup ({
plugins: {
h1style: apply`
uppercase
text-6xl
font-thin
`,
},
});
const h1style2 = apply `uppercase text-6xl font-thin`;
export let name;
</script>
<main>
<h1 class={tw`h1style`}>Hello {name}!</h1>
<p>Visit the <a href="https://svelte.dev/tutorial" class={tw`italic`}>Svelte tutorial</a> to learn how to build Svelte apps.</p>
</main>在上面的代码示例中,h1style2 ( const声明)可以工作,但是插件h1style不能工作。
如果有人能让这件事成功,我将不胜感激。
发布于 2021-01-25 09:35:31
我在Svelte中尝试了您的例子,它看起来很有效:https://svelte.dev/repl/e153da51e31a4b6c90cce63d9b6b3194?version=3.31.2
在这里,您可以找到我们的示例svelte项目:https://github.com/tw-in-js/example-svelte
需要注意的一点是,setup应该位于app初始化器中的组件或<script context="module">中的组件之外。这确保了每个应用程序只调用一次setup。
https://stackoverflow.com/questions/65879072
复制相似问题