Vue3 Snippets Highlight Formatters Generators For Visual Studio Code

December 22, 2020 · View on GitHub

Download Macketplace Github Page Eno Yao

English | 中文

Vue3 Snippets Highlight Formatters Generators For Visual Studio Code

Vue3 Snippets, Contains code highlighting, code snippets and formatting commonly used in vue2 and vue3.

1

You can turn on the statusbar Auto Format Vue switch at the bottom of vscode, which allows you to automatically format the vue file when you write it.

Or right-click to display the drop-down menu panel, click the Format Document menu item to format.

2

You can use Vue Generator Component commands in the folder to create new template components.

3

Snippets

Vue 3 Snippets

Including most of the API of Vue3. You can type reactive, choose reactive, and press ENTER, then const data = reactive({...}) appear on the screen.

PrefixJavaScript Snippet Content
importimport {...} from "@vue/composition-api"
importimport {...} from 'vue'
newVuenewVue({...})
defineComponentdefineComponent({...})
exportexport default { ... }
setupsetup(${...}) {...}
reactiveconst data = reactive({...})
watchwatch(..., ...)
watchFnwatch(() => {...})
watchArraywatch([...]) => {...}
watchEffectwatchEffect(() => {...})
computedcomputed(() => { get: () => {...}, set: () => {...}})
toRefstoRefs(...)
refref(...)
propsprops(...)
onBeforeMountonBeforeMount(...)
onMountedonMounted(...)
onBeforeUpdateonBeforeUpdate(...)
onUpdatedonUpdated(...)
onBeforeUnmountonBeforeUnmount(...)
onUnmountedonUnmounted(...)
onErrorCapturedonErrorCaptured(...)

Vue 2 Snippets

All code snippets of Vue 2 Snippets are also included here.

PrefixJavaScript Snippet Content
importimport ... from ...
newVuenew Vue({...})
VueConfigSilentVue.config.silent = true
VueConfigOptionMergeStrategiesVue.config.optionMergeStrategies
VueConfigDevtoolsVue.config.devtools = true
VueConfigErrorHandlerVue.config.errorHandler = function (err, vm, info) {...}
VueConfigWarnHandlerVue.config.warnHandler = function (msg, vm, trace) {...}
VueConfigIgnoredElementsVue.config.ignoredElements = [''] \
VueConfigKeyCodesVue.config.keyCodes
VueConfigPerformanceVue.config.performance = true
VueConfigProductionTipVue.config.productionTip = false
vueExtendVue.extend( options )
VueNextTickVue.nextTick( callback, [context] )
VueNextTickThenVue.nextTick( callback, [context] ).then(function(){ })
VueSetVue.set( target, key, value )
VueDeleteVue.delete( target, key )
VueDirectiveVue.directive( id, [definition] )
VueFilterVue.filter( id, [definition] )
VueComponentVue.component( id, [definition] )
VueUseVue.use( plugin )
VueMixinVue.mixin({ mixin })
VueCompileVue.compile( template )
VueVersionVue.version
datadata() { return {} }
watchWithOptionskey: { deep: true, immediate: true, handler: function () { } }
vmData${this, vm}.$data
vmProps${this, vm}.$props
vmEl${this, vm}.$el
vmOptions${this, vm}.$options
vmParent${this, vm}.$parent
vmRoot${this, vm}.$root
vmChildren${this, vm}.$children
vmSlots${this, vm}.$slots
vmScopedSlots${this, vm}.$scopedSlots.default({})
vmRefs${this, vm}.$refs
vmIsServer${this, vm}.$isServer
vmAttrs${this, vm}.$attrs
vmListeners${this, vm}.listeners
vmWatch${this, vm}.$watch( expOrFn, callback, [options] )
vmSet${this, vm}.$set( object, key, value )
vmDelete${this, vm}.$delete( object, key )
vmOn${this, vm}.$on( event, callback )
vmOnce${this, vm}.$once( event, callback )
vmOff${this, vm}.$off( [event, callback] )
vmEmit${this, vm}.$emit( event, […args] )
vmMount${this, vm}.$mount( [elementOrSelector] )
vmForceUpdate${this, vm}.$forceUpdate()
vmNextTick${this, vm}.$nextTick( callback )
vmDestroy${this, vm}.$destroy()
rendererconst renderer = require('vue-server-renderer').createRenderer()
createRenderercreateRenderer({ })
preventDefaultpreventDefault();
stopPropagationstopPropagation();

PrefixHTML Snippet Content
template<template></template>
script<script></script>
style<style></style>
vTextv-text=msg
vHtmlv-html=html
vShowv-show
vIfv-if
vElsev-else
vElseIfv-else-if
vForWithoutKeyv-for
vForv-for="" :key=""
vOnv-on
vBindv-bind
vModelv-model
vPrev-pre
vCloakv-cloak
vOncev-once
key:key
refref
slotAslot=""
slotE<slot></slot>
slotScopeslot-scope=""
component<component :is=''></component>
keepAlive<keep-alive></keep-alive>
transition<transition></transition>
transitionGroup<transition-group></transition-group>
enterClassenter-class=''
leaveClassleave-class=''
appearClassappear-class=''
enterToClassenter-to-class=''
leaveToClassleave-to-class=''
appearToClassappear-to-class=''
enterActiveClassenter-active-class=''
leaveActiveClassleave-active-class=''
appearActiveClassappear-active-class=''
beforeEnterEvent@before-enter=''
beforeLeaveEvent@before-leave=''
beforeAppearEvent@before-appear=''
enterEvent@enter=''
leaveEvent@leave=''
appearEvent@appear=''
afterEnterEvent@after-enter=''
afterLeaveEvent@after-leave=''
afterAppearEvent@after-appear=''
enterCancelledEvent@enter-cancelled=''
leaveCancelledEvent@leave-cancelled=''
appearCancelledEvent@appear-cancelled=''

PrefixVue Router Snippet Content
routerLink<router-link></router-link>
routerView<router-view></router-view>
toto=""
tagtag=""
newVueRouterconst router = newVueRouter({ })
routerBeforeEachrouter.beforeEach((to, from, next) => { }
routerBeforeResolverouter.beforeResolve((to, from, next) => { }
routerAfterEachrouter.afterEach((to, from) => { }
routerPushrouter.push()
routerReplacerouter.replace()
routerGorouter.back()
routerBackrouter.push()
routerForwardrouter.forward()
routerGetMatchedComponentsrouter.getMatchedComponents()
routerResolverouter.resolve()
routerAddRoutesrouter.addRoutes()
routerOnReadyrouter.onReady()
routerOnErrorrouter.onError()
routesroutes: []
beforeEnterbeforeEnter: (to, from, next) => { }
beforeRouteEnterbeforeRouteEnter (to, from, next) { }
beforeRouteLeavebeforeRouteLeave (to, from, next) { }
scrollBehaviorscrollBehavior (to, from, savedPosition) { }

PrefixVuex Snippet Content
newVuexStoreconst store = new Vuex.Store({})
mapGettersimport { mapGetters } from 'vuex'
mapMutationsimport { mapMutations } from 'vuex'
mapActionsimport { mapActions } from 'vuex'
statestate
mutationsmutations
actionsactions
modulesmodules
pluginsplugins
dispatchdispatch
subscribesubscribe
registerModuleregisterModule
unregisterModuleunregisterModule
hotUpdatehotUpdate

PrefixNuxt.js Snippet Content
nuxt<nuxt/>
nuxtChild<nuxt-child/>
nuxtLink<nuxt-link to=""/>
asyncDataasyncData() {}

Extension Settings

The configuration parameters are as follows:

vue3snippets.arrowParens
vue3snippets.bracketSpacing
vue3snippets.endOfLine
vue3snippets.htmlWhitespaceSensitivity
vue3snippets.insertPragma
vue3snippets.jsxBracketSameLine
vue3snippets.jsxSingleQuote
vue3snippets.printWidth
vue3snippets.proseWrap
vue3snippets.quoteProps
vue3snippets.requirePragma
vue3snippets.semi
vue3snippets.singleQuote
vue3snippets.tabWidth
vue3snippets.trailingComma
vue3snippets.useTabs
vue3snippets.vueIndentScriptAndStyle
KeyExampleDefault
vue3snippets.printWidth10/20/30/40/n80
vue3snippets.tabWidth1/2/3/4/n2
vue3snippets.singleQuotefalse/truefalse
vue3snippets.trailingCommanone/es5/alles5
vue3snippets.bracketSpacingtruetrue
vue3snippets.jsxBracketSameLinefalse/truefalse
vue3snippets.semifalse/truetrue
vue3snippets.requirePragmafalse/truefalse
vue3snippets.insertPragmafalse/truefalse
vue3snippets.useTabsfalse/truefalse
vue3snippets.proseWrappreserve/always/neverpreserve
vue3snippets.arrowParensavoid/alwaysalways
vue3snippets.jsxSingleQuotefalse/truefalse
vue3snippets.htmlWhitespaceSensitivitycss/strict/ignorecss
vue3snippets.vueIndentScriptAndStylefalse/truefalse
vue3snippets.endOfLineauto/lf/crlf/crlf
vue3snippets.quotePropsas-needed/consistent/preserveas-needed

Tutorial

Attached some Vue Chinese tutorials, hope to help you quickly get started:

Thanks

Tencent Alloyteam Team && Qian Feng Team

Eno Yao

Aaron Xie

DK Lan

Yong

Li Ting

Xin

Lemon

Jing

Lin

Tian Fly

If you enjoy front end, you should have it! xie, yao, yong, ting, jing, lin, tian, xin, xia, dk and lemon ~ Waiting for you in our heart!

Requirements

If you think it's useful, you can leave us a message and like it, Your support is our driving force😀

License

Vue3 Snippets is released under the MIT.