Svelte – Declaring Props

0 min read


Okay guys welcome back to our channel.. kita lanjutkan untuk svelte kita yah.. Kali ini gas lansung ke Declaring props.. yap kita akan buat component beserta propsnya untuk digunakan kapanpun dan dimanapun ya… oke cekidot…

pertama buat file Nested.svelte

<script>
	export let answer;
</script>

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

dan kita import di App.svelte

<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}/>

</main>

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

result :

jadi mudah kan… okay link github ada disini.. cyaaaa…

Bima Sena

Leave a Reply

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