Skip to content

Commit b91b590

Browse files
author
Corentin Andre
committed
Vuex support and add v-bind
1 parent b586b6f commit b91b590

File tree

2 files changed

+92
-17
lines changed

2 files changed

+92
-17
lines changed

README.md

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Vuejs-snippets
2-
Collection of Vue.js snippets for version 2.0+
2+
Collection of Vue.js snippets for version 2.0+.
3+
Also supports Vuex, vue-router still missing.
4+
5+
Feel free to contribute to this package by submitting a PR!
36

47
## Usage
58

@@ -28,20 +31,27 @@ v-model <!--Vuejs binding for model binding-->
2831

2932
### Javascript
3033
```javascript
31-
beforeCreate //Vuejs instance lifecycle hook for beforeCreate
32-
created //Vuejs instance lifecycle hook for created
33-
beforeMount //Vuejs instance lifecycle hook for beforeMount
34-
mounted //Vuejs instance lifecycle hook for mounted
35-
beforeUpdate //Vuejs instance lifecycle hook for beforeUpdate
36-
updated //Vuejs instance lifecycle hook for updated
37-
beforeUpdate //Vuejs instance lifecycle hook for beforeUpdate
38-
updated //Vuejs instance lifecycle hook for updated
39-
beforeDestroy //Vuejs instance lifecycle hook for beforeDestroy
40-
destroyed //Vuejs instance lifecycle hook for destroyed
41-
vwatch //Vuejs way to watch instance properties
42-
methods //Vuejs methods event handlers
43-
components //Use it when you want to add child components to parent component.
44-
props //Vuejs way to pass data to child components
45-
vcomputed //Vuejs computed property
34+
beforeCreate // Vuejs instance lifecycle hook for beforeCreate
35+
created // Vuejs instance lifecycle hook for created
36+
beforeMount // Vuejs instance lifecycle hook for beforeMount
37+
mounted // Vuejs instance lifecycle hook for mounted
38+
beforeUpdate // Vuejs instance lifecycle hook for beforeUpdate
39+
updated // Vuejs instance lifecycle hook for updated
40+
beforeUpdate // Vuejs instance lifecycle hook for beforeUpdate
41+
updated // Vuejs instance lifecycle hook for updated
42+
beforeDestroy // Vuejs instance lifecycle hook for beforeDestroy
43+
destroyed // Vuejs instance lifecycle hook for destroyed
44+
vwatch // Vuejs way to watch instance properties
45+
methods // Vuejs methods event handlers
46+
components // Use it when you want to add child components to parent component.
47+
props // Vuejs way to pass data to child components
48+
vcomputed // Vuejs computed property
4649
```
4750

51+
### Vuex
52+
```javascript
53+
vstore // Vuex template for a complete store with state,getters,actions and mutations
54+
vmut // Vuex mutation snippet
55+
vact // Vuex action snippet
56+
vget // Vuex getter snippet
57+
```

snippets/snippets.cson

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
".meta.tag":
4242
'v-for':
4343
'prefix': 'v-for'
44-
'body': 'v-for=\"${1:elem} in ${2:elemArray}\"'
44+
'body': 'v-for=\"${1:elem} in ${2:elemArray}\" :key=\"${1:elem}.${3:key}\"'
4545
'description': 'Vuejs binding for list rendering'
4646
'descriptionMoreURL': 'https://vuejs.org/v2/guide/list.html#v-for'
4747
'v-if':
@@ -69,6 +69,9 @@
6969
'body': 'v-model=\"${1:model}\"'
7070
'description': 'Vuejs binding for model binding'
7171
'descriptionMoreURL': 'https://vuejs.org/v2/guide/forms.html'
72+
'v-bind':
73+
'prefix': 'v-bind'
74+
'body': ':${1:attribute}=\"${2}\"'
7275

7376
'.source.js':
7477
'Vue computed':
@@ -199,3 +202,65 @@
199202
'body': 'props: [\'${1:propName}\']'
200203
'description': 'Vuejs way to pass data to child components'
201204
'descriptionMoreURL': 'https://vuejs.org/v2/guide/components.html#Props'
205+
206+
'.source.js.jsx':
207+
'Store template':
208+
'prefix': 'vstore'
209+
'body': """
210+
//Imports on top
211+
212+
const state = {
213+
// Initial state of ${1:your store}
214+
215+
};
216+
217+
const getters = {
218+
// Getters to access ${1:your store} values
219+
220+
};
221+
222+
const actions = {
223+
// Asynchronous mutations commits to modify ${1:your store}
224+
225+
}
226+
227+
const mutations = {
228+
// Synchronous modifications of ${1: your store}
229+
}
230+
231+
export default {
232+
state,
233+
getters,
234+
actions,
235+
mutations
236+
}
237+
"""
238+
'description': 'Vuex template for a complete store to be imported as a module or as a single file store.'
239+
'descriptionMoreURL': 'https://vuex.vuejs.org/en/structure.html'
240+
'Mutation template':
241+
'prefix': 'vmut'
242+
'body': """
243+
[${1:mutation_type}] (state, $2) {
244+
$3
245+
}
246+
"""
247+
'description': 'Vuex snippet for mutations.'
248+
'descriptionMoreURL': 'https://vuex.vuejs.org/en/mutations.html'
249+
'Action template':
250+
'prefix': 'vact'
251+
'body': """
252+
${1:action_name}({
253+
commit,
254+
state
255+
}, $2) {
256+
// Asynchronous stuff here.
257+
$3
258+
}
259+
"""
260+
'description': 'Vuex snippet for actions.'
261+
'descriptionMoreURL': 'https://vuex.vuejs.org/en/actions.html'
262+
'Getter template':
263+
'prefix': 'vget'
264+
'body': '${1:variable}: () => state.${1:variable}'
265+
'description': 'Vuex snippet for getters.'
266+
'descriptionMoreURL': 'https://vuex.vuejs.org/en/getters.html'

0 commit comments

Comments
 (0)