Svelte – Default Value

0 min read


Alright guysss welcome back to our channel.. okay balik lagi kita langsung aja ke project dan materi berikutnyaa…

kita ubah file Nested.svelte menjadi seperti ini :

<script>
	export let answer = 'a mystery';
</script>

<p>The answer is {answer}</p>

dan import di App.svelte ada tambahan sedikit sehingga akan seperti ini ya guyss :

<script>
	
	import Counter from './components/Counter.svelte'
	import Toggle from './components/Toggle.svelte'
	import Img from './components/Img.svelte'
	import String from './components/String.svelte'
	import Statement from './components/Statement.svelte'
	import Condition from './components/Condition.svelte';
	import Nested from './components/Nested.svelte';

	export let name;
</script>

<main>
	<h1>Hello {name}!</h1>
	<p>Visit the <a href="https://svelte.dev/tutorial">Svelte tutorial</a> to learn how to build Svelte apps.</p>
	<Counter />
	<Toggle />
	<Img />
	<String />
	<Statement />
	<Condition />
	<Nested answer={42}/>
	<Nested/>

</main>

<link href="https://fonts.googleapis.com/css?family=Overpass:100,400" rel="stylesheet">

result :

Jadi disini kita sudah berhasil menentukan default value dan mengoverridenya .. link github ada disini ya guysss.. cyaaa…

Bima Sena

Leave a Reply

Your email address will not be published. Required fields are marked *