The essential collection of Svelte V2 Snippets.
Snippet | Renders |
---|---|
svscript |
Svelte Script |
svscriptfull |
Svelte Script Extended |
svexport |
Svelte Export Default |
svexportfull |
Svelte Export Extended |
svif |
Svelte if block |
svifelse |
Svelte if else block |
svifelseif |
Svelte if else if block |
sveach |
Svelte each block |
sveachelse |
Svelte each else block |
svoncreate |
Svelte oncreate lifecycle method |
svonstate |
Svelte onstate lifecycle method |
svonstateevent |
Svelte state event |
svonupdate |
Svelte onupdate lifecycle method |
svonupdateevent |
Svelte update event |
svondestroy |
Svelte ondestroy lifecycle method |
svevent |
Svelte event |
svcomputed |
Svelte computed properties wrapper |
svcomponents |
Svelte components wrapper |
svmethods |
Svelte methods wrapper |
svhelpers |
Svelte helpers wrapper |
svactions |
Svelte actions wrapper |
svget |
this.get() |
svgetd |
this.get() with declaration |
svset |
this.set() |
<script>
export default {
data(){
return {
|
}
}
}
</script>
<script>
import | from '|';
export default {
components:{
|
},
computed:{
|: ({|}) => |
},
data(){
return {
|
}
},
oncreate(){
var self = this;
|
},
methods: {
|
}
}
</script>
export default {
data(){
return {
|
}
}
}
import | from '|';
export default {
components:{
|
},
computed:{
|: ({|}) => |
},
data(){
return {
|
}
},
oncreate(){
var self = this;
|
},
methods: {
|
}
}
{#if }
{:elseif}
{:else}
{/if}
{#if |}
|
{/if}
{#if |}
|
{:else}
|
{/if}
{#if |}
|
{:elseif}
|
{:else}
|
{/if}
{#each | as |}
|
{/each}
{#each | as |}
|
{:else}
|
{/each}
oncreate(){
var self = this;
|
}
onstate({changed, current, previous}){
var self = this;
|
}
onupdate({changed, current, previous}){
var self = this;
|
}
ondestroy(){
var self = this;
|
}
this.on('|', (|) => {
|
});
state
event this.on('state', ({changed, current, previous}) => {
|
});
update
event this.on('update', ({changed, current, previous}) => {
|
});
computed: {
|: ({|}) => |
},
methods: {
|(){
|
}
},
components: {
|
},
helpers: {
|
},
get
method this.get()|;
get
method with declaration var {|} = this|.get();
set
method this.set({ | : | });