组件导入
和vue和react一样,在script标签中通过import来引入想要引入的.svelte组件
这里就简单看一个例子就好
// Header.svelte
<script>
let text = "This is Header";
</script>
<h1>{text}</h1>
<style>
h1 {
font-family: 'Courier New', Courier, monospace;
color: red;
}
</style>
利用import进行引入
// App.svelte
<script>
import Header from './Header.svelte';
let name = 'world';
</script>
<Header />
<div>hello {name.toUpperCase()}</div>
<style>
div {
color: blue;
font-size: 18px;
line-height: 20px;
font-weight: 500;
}
</style>
- 实现效果
5. 插入html字符串
在react