Skip to content

Commit 4637ff7

Browse files
author
Dilawar Singh
committed
added vue snippets.
1 parent 305f0f2 commit 4637ff7

File tree

1 file changed

+189
-0
lines changed

1 file changed

+189
-0
lines changed

snippets/vue.snippets

+189
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# This snippet file enables vue files to use tabs for html, js and css. It also
2+
# includes some vue-specific html-like snippets, as well as some general
3+
# boilerplate code for vue.
4+
5+
extends html, javascript, css
6+
7+
# These snippets form a port of Sarah Drasner's vue-sublime-snippets
8+
9+
# some html-like snippets
10+
11+
snippet slot
12+
<slot></slot>
13+
14+
snippet template
15+
<template></template>
16+
17+
snippet transition
18+
<transition></transition>
19+
20+
# The following snippets create more complex boilerplate code.
21+
22+
snippet vbase
23+
<template>
24+
<div>
25+
26+
</div>
27+
</template>
28+
29+
<script>
30+
export default{
31+
${0}
32+
}
33+
</script>
34+
35+
<style scoped>
36+
37+
</style>
38+
39+
snippet vimport:c
40+
import ${1:Name} from './components/$1.vue';
41+
42+
export default {
43+
components: {
44+
$1
45+
}
46+
}
47+
48+
snippet vactions
49+
actions: {
50+
${1:updateValue}({commit}, ${2:payload}) {
51+
commit($1, $2);
52+
}
53+
}
54+
55+
# Add in js animation hooks
56+
snippet vanim:js:el
57+
<transition
58+
@before-enter="beforeEnter"
59+
@enter="enter"
60+
@after-enter="afterEnter"
61+
@enter-cancelled="enterCancelled"
62+
63+
@before-Leave="beforeLeave"
64+
@leave="leave"
65+
@after-leave="afterLeave"
66+
@leave-cancelled="leaveCancelled"
67+
:css="false">
68+
69+
</transition>
70+
71+
snippet vanim:js:method
72+
methods: {
73+
beforeEnter(el) {
74+
console.log('beforeEnter');
75+
},
76+
enter(el, done) {
77+
console.log('enter');
78+
done();
79+
},
80+
afterEnter(el) {
81+
console.log('afterEnter');
82+
},
83+
enterCancelled(el, done) {
84+
console.log('enterCancelled');
85+
},
86+
beforeLeave(el) {
87+
console.log('beforeLeave');
88+
},
89+
leave(el, done) {
90+
console.log('leave');
91+
done();
92+
},
93+
afterLeave(el) {
94+
console.log('afterLeave');
95+
},
96+
leaveCancelled(el, done) {
97+
console.log('leaveCancelled');
98+
}
99+
}
100+
101+
snippet vcl
102+
@click="${1}"
103+
104+
snippet vdata
105+
data() {
106+
return {
107+
${1:key}: ${2:value}
108+
};
109+
}
110+
111+
snippet vfilter
112+
filters: {
113+
${1:fnName}: function(${2:value}) {
114+
return;
115+
}
116+
}
117+
118+
snippet vfor
119+
<div v-for="${1:item} in ${2:items}" :key="$1.id">
120+
{{ $1 }}
121+
</div
122+
123+
snippet vgetters
124+
getters: {
125+
${1:value}: state => {
126+
return state.$1;
127+
}
128+
}
129+
130+
snippet vimport
131+
import ${1:New} from './components/$1.vue';
132+
133+
snippet vkeep
134+
<keep-alive>
135+
<component :is="">
136+
<p>default</p>
137+
</component>
138+
</keep-alive>
139+
140+
snippet vmixin
141+
const ${1:mixinName} = {
142+
mounted() {
143+
console.log('hello from mixin!')
144+
},
145+
}
146+
const ${2:Component} = Vue.extend({
147+
mixins: [$1]
148+
})
149+
150+
snippet vmutations
151+
mutations: {
152+
${1:updateValue}(state, ${3:payload}) => {
153+
state.${2:value} = $3;
154+
}
155+
}
156+
157+
snippet vprops:d
158+
${1:propName}: {
159+
type: ${2:Number},
160+
default: ${0}
161+
},
162+
163+
snippet vprops
164+
${1:propName}: {
165+
type: ${2:Number}
166+
},
167+
168+
snippet vstore
169+
import Vue from 'vue';
170+
import Vuex from 'vuex';
171+
172+
Vue.use(Vuex);
173+
174+
export const store = new Vuex.Store({
175+
state: {
176+
${1:key}: ${2:value}
177+
}
178+
});
179+
180+
181+
# vue-i18n snippets https://github.com/kazupon/vue-i18n
182+
183+
snippet trans
184+
$t('$1')
185+
186+
# Translation with parameter
187+
snippet transc
188+
$t('$1', { $2: $3 })
189+

0 commit comments

Comments
 (0)