vue2.code-snippets
1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{
"Vue 2 Component": {
"prefix": "vue2",
"body": [
"<template>",
" <div class=\"$1\">",
" $0",
" </div>",
"</template>",
"",
"<script>",
"export default {",
" name: '$2',",
" data() {",
" return {",
" $3",
" };",
" },",
" props: {",
" $4",
" },",
" computed: {",
" $5",
" },",
" methods: {",
" $6",
" },",
" mounted() {",
" $7",
" }",
"};",
"</script>",
"",
"<style scoped lang=\"scss\">",
"$8",
"</style>"
],
"description": "Vue 2 单文件组件模板"
},
"Vuex Store Template (Vue2)": {
"prefix": "vuexstore2",
"body": [
"export default {",
" state: {",
" ${1:count}: ${2:0},",
" },",
" getters: {",
" ${3:get${1/(.*)/${1:/capitalize}/}}: state => state.${1},",
" },",
" mutations: {",
" set${1/(.*)/${1:/capitalize}/}(state, payload) {",
" state.${1} = payload;",
" },",
" increment${1/(.*)/${1:/capitalize}/}(state, payload = 1) {",
" state.${1} += payload;",
" }",
" },",
" actions: {",
" ${4:increment${1/(.*)/${1:/capitalize}/}Async}({ commit }, payload) {",
" setTimeout(() => {",
" commit('increment${1/(.*)/${1:/capitalize}/}', payload);",
" }, 1000);",
" }",
" },",
"};"
],
"description": "Vue 2 + Vuex 3 的 store 模板"
}
}