Svelte Practice
Svelte Practice
Adding data
2. Adding dynamic data
3. styling using markup
4. Import component and include inside another component.[Nesting components]
5. Sanitising html i.e. special symbol elimination.
function addNumber() {
numbers.push(numbers.length + 1);
numbers = numbers;
}
3. props - https://www.youtube.com/watch?v=zujl4wrRnFA
1. declaring props
Nested.svelte
<script>
export let answer;
export let val;
</script>
App.svelte
<script>
import Nested from './Nested.svelte';
</script>
3. spread operator
<script>
import Info from './Info.svelte';
const pkg = {
name: 'svelte',
version: 3,
speed: 'blazing',
website: 'https://svelte.dev'
};
</script>
<script>
export let name;
export let version;
export let speed;
export let website;
</script>
<p>
The <code>{name}</code> package is {speed} fast.
Download version {version} from <a
href="https://www.npmjs.com/package/{name}">npm</a>
and <a href={website}>learn more here</a>
</p>
4. conditional
1. if
2. if else
3. if else ladder
4. for loop
5. keyed each unique key
6. await block
5. Events
1. Dom Event
2. inline event handler
<div on:mousemove="{e => m = { x: e.clientX, y: e.clientY }}">
The mouse position is {m.x} x {m.y}
</div>
3. Event modifiers
4. Event dispatcher
https://www.youtube.com/watch?v=yCkYm4zze8I
5. Event forwarding
https://www.youtube.com/watch?
v=SaMils0yx7s&list=PL4cUxeGkcC9hlbrVO_2QFVqVPhlZmz7tO&index=12
6.
1. Bind input element
2. Bind numeric type
3. Bind checkbox
4. Group input [video]
5. TextArea input
6. Select Bind [video]
7. Multiple select
8. Contenteditable bind
9. media elements
10. Dimensions
11.
7. Life cycle
1. onMount
2. onDestroy
3.