1
0
Fork 0
mirror of synced 2024-11-14 21:18:58 -05:00
ultimate-vim/sources_non_forked/vim-snippets/snippets/vue.snippets

190 lines
2.8 KiB
Text
Raw Normal View History

2017-07-06 08:57:35 -04:00
# This snippet file enables vue files to use tabs for html, js and css. It also
2019-03-27 11:08:56 -04:00
# includes some vue-specific html-like snippets, as well as some general
2017-07-06 08:57:35 -04:00
# boilerplate code for vue.
2019-03-27 11:08:56 -04:00
extends html, javascript, css
2017-07-06 08:57:35 -04:00
# These snippets form a port of Sarah Drasner's vue-sublime-snippets
# some html-like snippets
snippet slot
<slot></slot>
snippet template
<template></template>
2019-03-27 11:08:56 -04:00
snippet transition
2017-07-06 08:57:35 -04:00
<transition></transition>
# The following snippets create more complex boilerplate code.
snippet vbase
<template>
<div>
</div>
</template>
<script>
export default{
2019-03-27 11:08:56 -04:00
${0}
}
2017-07-06 08:57:35 -04:00
</script>
2019-03-27 11:08:56 -04:00
2017-07-06 08:57:35 -04:00
<style scoped>
</style>
2019-03-27 11:08:56 -04:00
2017-07-06 08:57:35 -04:00
snippet vimport:c
2019-03-27 11:08:56 -04:00
import ${1:Name} from './components/$1.vue';
2017-07-06 08:57:35 -04:00
2019-03-27 11:08:56 -04:00
export default {
2017-07-06 08:57:35 -04:00
components: {
2019-03-27 11:08:56 -04:00
$1
2017-07-06 08:57:35 -04:00
}
}
2019-03-27 11:08:56 -04:00
snippet vactions
2017-07-06 08:57:35 -04:00
actions: {
2019-03-27 11:08:56 -04:00
${1:updateValue}({commit}, ${2:payload}) {
commit($1, $2);
2017-07-06 08:57:35 -04:00
}
}
# Add in js animation hooks
2019-03-27 11:08:56 -04:00
snippet vanim:js:el
<transition
2017-07-06 08:57:35 -04:00
@before-enter="beforeEnter"
@enter="enter"
@after-enter="afterEnter"
@enter-cancelled="enterCancelled"
2019-03-27 11:08:56 -04:00
2017-07-06 08:57:35 -04:00
@before-Leave="beforeLeave"
@leave="leave"
@after-leave="afterLeave"
@leave-cancelled="leaveCancelled"
:css="false">
2019-03-27 11:08:56 -04:00
2017-07-06 08:57:35 -04:00
</transition>
2019-03-27 11:08:56 -04:00
2017-07-06 08:57:35 -04:00
snippet vanim:js:method
methods: {
2019-03-27 11:08:56 -04:00
beforeEnter(el) {
console.log('beforeEnter');
},
enter(el, done) {
console.log('enter');
done();
},
afterEnter(el) {
console.log('afterEnter');
},
enterCancelled(el, done) {
console.log('enterCancelled');
},
beforeLeave(el) {
console.log('beforeLeave');
},
leave(el, done) {
console.log('leave');
done();
},
afterLeave(el) {
console.log('afterLeave');
},
leaveCancelled(el, done) {
console.log('leaveCancelled');
}
2017-07-06 08:57:35 -04:00
}
2019-03-27 11:08:56 -04:00
snippet vcl
@click="${1}"
2017-07-06 08:57:35 -04:00
snippet vdata
2019-03-27 11:08:56 -04:00
data() {
return {
${1:key}: ${2:value}
};
2017-07-06 08:57:35 -04:00
}
snippet vfilter
filters: {
2019-03-27 11:08:56 -04:00
${1:fnName}: function(${2:value}) {
return;
}
2017-07-06 08:57:35 -04:00
}
snippet vfor
2019-03-27 11:08:56 -04:00
<div v-for="${1:item} in ${2:items}" :key="$1.id">
{{ $1 }}
2017-07-06 08:57:35 -04:00
</div
snippet vgetters
getters: {
2019-03-27 11:08:56 -04:00
${1:value}: state => {
return state.$1;
2017-07-06 08:57:35 -04:00
}
}
2019-03-27 11:08:56 -04:00
snippet vimport
import ${1:New} from './components/$1.vue';
2017-07-06 08:57:35 -04:00
snippet vkeep
<keep-alive>
2019-03-27 11:08:56 -04:00
<component :is="">
<p>default</p>
</component>
2017-07-06 08:57:35 -04:00
</keep-alive>
snippet vmixin
2019-03-27 11:08:56 -04:00
const ${1:mixinName} = {
mounted() {
console.log('hello from mixin!')
},
2017-07-06 08:57:35 -04:00
}
2019-03-27 11:08:56 -04:00
const ${2:Component} = Vue.extend({
mixins: [$1]
2017-07-06 08:57:35 -04:00
})
snippet vmutations
2019-03-27 11:08:56 -04:00
mutations: {
${1:updateValue}(state, ${3:payload}) => {
state.${2:value} = $3;
2017-07-06 08:57:35 -04:00
}
}
snippet vprops:d
2019-03-27 11:08:56 -04:00
${1:propName}: {
type: ${2:Number},
default: ${0}
2017-07-06 08:57:35 -04:00
},
2019-03-27 11:08:56 -04:00
snippet vprops
${1:propName}: {
type: ${2:Number}
2017-07-06 08:57:35 -04:00
},
2019-03-27 11:08:56 -04:00
snippet vstore
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
export const store = new Vuex.Store({
state: {
${1:key}: ${2:value}
}
});
2019-11-16 10:28:42 -05:00
# vue-i18n snippets https://github.com/kazupon/vue-i18n
snippet trans
$t('$1')
# Translation with parameter
snippet transc
$t('$1', { $2: $3 })