Examples
- Introduction
- Reactivity
- Props
- Logic
- Events
- Bindings
- Lifecycle
- Stores
- Motion
- Transitions
- Animations
- Easing
- SVG
- Actions
- Classes
- Component composition
- Context API
- Special elements
- Module context
- Debugging
- 7GUIs
- Miscellaneous
App.svelte
Nested.svelte
9
1
2
3
4
5
6
›
⌄
<script>
export let answer = 'a mystery';
</script>
<p>The answer is {answer}</p>
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
›
⌄
⌄
⌄
⌄
⌄
⌄
⌄
⌄
⌄
⌄
⌄
/* Nested.svelte generated by Svelte v4.2.15 */
import {
SvelteComponent,
append,
detach,
element,
init,
insert,
noop,
safe_not_equal,
set_data,
text
} from "svelte/internal";
import "svelte/internal/disclose-version";
function create_fragment(ctx) {
let p;
let t0;
let t1;
return {
c() {
p = element("p");
t0 = text("The answer is ");
t1 = text(/*answer*/ ctx[0]);
},
m(target, anchor) {
insert(target, p, anchor);
append(p, t0);
append(p, t1);
},
p(ctx, [dirty]) {
if (dirty & /*answer*/ 1) set_data(t1, /*answer*/ ctx[0]);
},
i: noop,
o: noop,
d(detaching) {
if (detaching) {
detach(p);
}
}
};
}
function instance($$self, $$props, $$invalidate) {
let { answer = 'a mystery' } = $$props;
$$self.$$set = $$props => {
if ('answer' in $$props) $$invalidate(0, answer = $$props.answer);
};
return [answer];
}
class Nested extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, { answer: 0 });
}
}
export default Nested;
result = svelte.compile(source, {
generate:
css:
});9
1
›
/* Add a <style> tag to see compiled CSS */