svelte-state-example-mynumbers
About this project
- Have two components: App and Numbers
- Communicate between these components
Quickstart
About Svelte
Howto work with SvelteJS
- Have local NodeJS installation. Recommendation: Use NVM.
- Install degit to get starter files.
- Start project with
- "degit sveltejs/template myproject"
- cd myproject
- "atom ." or "code ."
- Use IDE like Atom or Visual Studio Code
- Install Package for syntax highlighting like "svelte-ide" or "Svelte"
How to work with this project
There are two components:
- srv/App.svelte
- src/components/Mynumbers.svelte
Each component has three sections:
- Script
- HTML
- Style
- There are comments in every component to explain what is going on.
In the App component you see that Mynumbers component is embedded in HTML section.
- There are three attributes given to the Mynumbers component:
- numbers (this is our number array)
- on:click (this is ONE way to route an event between components)
- add_num (a function that can be called from another component)
How to get it running
- npm install
- npm run dev
- open http://localhost:5000