1.defineComponent语法
{
"Print to console": {
"prefix": "vue3",
"body": [
"<template>",
"<div class=\"container\">",
" ",
"</div>",
"</template>",
"<script>",
" ",
"import { defineComponent, getCurrentInstance, onMounted, onBeforeMount, reactive, toRefs } from 'vue'",
"export default defineComponent({",
"name:'',",
"props: { },",
"emits:[],",
"components: {",
" ",
"},",
"setup(props, ctx){",
"const { proxy } = getCurrentInstance();",
"const state = reactive({",
" ",
"})",
"onMounted(() => {",
" ",
"})",
"onBeforeMount(() => {",
" ",
"})",
" ",
"return {",
"...toRefs(state),",
" ",
"}",
"}",
"})",
"</script>",
"<style scoped lang=\"scss\">",
" ",
"</style>",
" "
],
"description": "A vue file template"
}
}
2.setup语法
{
"Print to console": {
"prefix": "v-setup",
"body": [
"<template>",
"<div class=\"container\">",
" ",
"</div>",
"</template>",
"<script setup>",
"import { getCurrentInstance, onBeforeMount, onMounted, reactive } from 'vue'",
"const { proxy } = getCurrentInstance();",
"const emits = defineEmits([])",
"const props = defineProps({",
" ",
"})",
"const state = reactive({",
" ",
"})",
"onBeforeMount(() => {",
" ",
"})",
"onMounted(() => {",
" ",
"})",
"defineExpose({ state })",
" ",
"</script> ",
"<style lang=\"scss\" scoped>",
" ",
"</style>"
],
"description": "vue3"
}
}
标签:片段,const,onBeforeMount,代码,onMounted,getCurrentInstance,reactive,state,Vue3
From: https://www.cnblogs.com/StevenYF/p/17874576.html