Skip to main content

Ta có thể dễ dàng cho vào một giá trị mặc định cho property trong Nested.svelte:

Nested.svelte
<script>
	export let answer = 'một bí mật';
</script>

Nếu bây giờ bạn thử thêm component thứ hai mà không có thuộc tính answer, nó sẽ tự rơi về giá trị mặc định:

App.svelte
<Nested answer={42}/>
<Nested />

Tiếp theo: Mở rộng thuộc tính

1
2
3
4
5
6
<script>
	import Nested from './Nested.svelte';
</script>
 
<Nested answer={42} />
 
initialising