Comments (2)
This is all excellent feedback, thanks. Will work more on the docs when I can, but briefly:
- Properties of
data
andcomputed
can be used in mustache tags and as arguments to event handlers. The same goes forhelpers
, which is really just an extension ofdata
(but I've found a lot of people get weirded out by having functions in an object called 'data') methods
are added to the component's prototype – i.e. if you have afoo
method than you will be able to docomponent.foo(...)
in your app. You can also call methods (built-in or custom) inside event handlers in your template – in anon:somevent='foo(bar)'
directive,foo(...)
must be a method,bar
must be a property ofdata
orcomputed
- Inside a method,
this
is always the component - In the event handler itself,
this
is the node – so<input on:input='log(this.value)'>
means 'call thelog
method with the value of the the<input>
'. Demo: https://svelte.technology/repl/?gist=b709873e61bbf7fed5d84ab0ca14ea86 - Name collisions will cause a compile time error – the compiler is strict, it won't let you make that sort of mistake
Hope this sheds some light!
from svelte.
Scope is a bit simpler in v3, and I think adequately covered in the documentation. Closing.
from svelte.
Related Issues (20)
- Setting a store to `undefined` and then trying to use it in a rune throws `state_unsafe_mutation` error HOT 7
- Svelte 5: Passing Date objects through `$state.snapshot()` turns it into a string
- HMR fails on next.179 and above HOT 8
- 🪲 sveltekit PROD bug with [email protected] using ternary in template HOT 1
- Svelte 5: state_unsafe_mutation Updating state inside a derived is forbidden. If the value should not be reactive, declare it without `$state` HOT 2
- Svelte 5: Automatically implement toJSON so state and properties are serialized. HOT 3
- Ternary in html attributes doesn't compile for production HOT 2
- Svelte 5 bug when moving mouse HOT 6
- $state, $bindable without backup value become 'undefined' in $derived HOT 5
- Svelte 5: SSR breaks rendering of Select component when HMR is enabled HOT 19
- Data returned from load function is stateless HOT 2
- Svelte 5: Add `class:list` directive HOT 5
- Individual states seemingly working like a singleton? I don't even know how to caption this HOT 1
- Distinguish between properties and attributes on custom elements HOT 10
- [REPL] modifying file name to same value wipes contents HOT 1
- `$props` aliasing allows invalid names HOT 7
- Svelte5: unexpected `Component` type errors HOT 4
- Proposal: Include README as component documentation upon packaging HOT 5
- Ability to ignore svelte warnings other than a11y HOT 2
- Svelte 5: only block root tags are checked for being closed HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svelte.