Component Format
Script Module
A <script>
tag with a context="module"
attribute runs once when the module first evaluates, rather than for each component instance. Values declared in this block are accessible from a regular <script>
(and the component markup) but not vice versa.
You can export
bindings from this block, and they will become exports of the compiled module.
You cannot export default
, since the default export is the component itself.
WARNING
Variables defined in module
scripts are not reactive — reassigning them will not trigger a rerender even though the variable itself will update. For values shared between multiple components, consider using a store.