vu2和vue3代码段

34 阅读1分钟
vscode左上角文件->首选项->配置用户代码片段
v2
{
  "Print to console": {
    "prefix": "vue",
    "body": [
      "<template>",
      "  <div class=''></div>",
      "</template>",
      "<script>",
      "export default {",
      "  name: '',",
      "  props: {},",
      "  components: {},",
      "  data() {",
      "    return {};",
      "  },",
      "  computed: {},",
      "  watch: {},",
      "  methods: {},",
      "  created() {},",
      "  mounted() {},",
      "  beforeDestroy() {}",
      "};",
      "</script>",
      "<style lang='scss' scoped>",
      "</style>"
    ],
    "description": "Log output to console"
  }
}
v3
{
  "Print to console": {
    "prefix": "v3",
    "body": [
      "<template>",
      "  <div></div>",
      "</template>",
      "",
      "<script setup lang=\"ts\">",
      "import {\n  ref,\n  reactive,\n  toRefs,\n  watch ,\n  onMounted,\n  getCurrentInstance\n} from 'vue'",
      "\n",
      "import { useRouter } from \"vue-router\"",
      "import { userGlobal } from '@/hooks/userGlobal'",
      "const router = useRouter();",
      "const { codeEnum,stateEnum,utils,$message } = userGlobal()",
      "\n",
      "const emit = defineEmits([\"\"])",
      "const props = defineProps({",
      "  propData: {",
      "    type: String,",
      "    default: ''",
      "  },",
      "})",
      "//const { } = toRefs(props);",
      "\n",
      "const { data } = toRefs(",
      "  reactive({",
      "    //定义数组和对象",
      "    data: \"\",",
      "  })",
      ");",

      "</script>",
      "<style lang=\"scss\" scoped>",
      "</style>"	
     ],
     "description": "vue3"
   }
}