Home

Awesome

<a href="https://marketplace.visualstudio.com/items?itemName=Wscats.vue"><img src="https://img.shields.io/badge/Download-60k+-orange" alt="Download" /></a> <a href="https://marketplace.visualstudio.com/items?itemName=Wscats.vue"><img src="https://img.shields.io/badge/Macketplace-v1.x-brightgreen" alt="Macketplace" /></a> <a href="https://github.com/Wscats/vue-snippets"><img src="https://img.shields.io/badge/Github Page-Wscats-yellow" alt="Github Page" /></a> <a href="https://github.com/Wscats"><img src="https://img.shields.io/badge/Author-Eno Yao-blueviolet" alt="Eno Yao" /></a>

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.

<!-- <a href="https://github.com/Wscats"><img src="https://api.netlify.com/api/v1/badges/b652768b-1673-42cd-98dd-3fd807b2ebca/deploy-status" alt="Status" /></a> --> <!-- <img src="./public/1.gif" /> --> <!-- ![Demo](public/1.gif) -->

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.

<!-- <img src="./public/2.gif" /> --> <!-- ![Demo](public/2.gif) -->

2

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

<img width="298" alt="3" src="https://user-images.githubusercontent.com/17243165/100542419-ab8abc00-3284-11eb-90a9-c5b6a83d9129.png">

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();
<br />
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=''
<br />
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) { }
<br />
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
<br />
PrefixNuxt.js Snippet Content
nuxt<nuxt/>
nuxtChild<nuxt-child/>
nuxtLink<nuxt-link to=""/>
asyncDataasyncData() {}
<!-- </details> -->

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

<details><summary><b>Tencent Alloyteam Team && Qian Feng Team</b></summary>
<img src="https://avatars1.githubusercontent.com/u/17243165?s=460&v=4" width="60px;"/><br /><sub>Eno Yao</sub><img src="https://avatars2.githubusercontent.com/u/5805270?s=460&v=4" width="60px;"/><br /><sub>Aaron Xie</sub><img src="https://avatars3.githubusercontent.com/u/12515367?s=460&v=4" width="60px;"/><br /><sub>DK Lan</sub><img src="https://avatars1.githubusercontent.com/u/30917929?s=460&v=4" width="60px;"/><br /><sub>Yong</sub><img src="https://avatars3.githubusercontent.com/u/33544236?s=460&v=4" width="60px;"/><br /><sub>Li Ting</sub><img src="https://avatars2.githubusercontent.com/u/50255537?s=400&u=cfd51a5f46862d14e92e032a5b7ec073b67a904b&v=4" width="60px;"/><br /><sub>Xin</sub><img src="https://avatars0.githubusercontent.com/u/39754159?s=400&v=4" width="60px;"/><br /><sub>Lemon</sub><img src="https://avatars3.githubusercontent.com/u/31915459?s=400&u=11ea9bc9baa62784208a29dddcd0a77789e9620f&v=4" width="60px;"/><br /><sub>Jing</sub><img src="https://avatars2.githubusercontent.com/u/24653988?s=400&u=76227871dea8d4b57162093fde63b7d52910145d&v=4" width="60px;"/><br /><sub>Lin</sub><img src="https://avatars2.githubusercontent.com/u/23230108?s=460&v=4" width="60px;"/><br /><sub>Tian Fly</sub>

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!

</details> <details><b><summary>Requirements</b></summary> </details>

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.