vscode-用户片段-vue.json

294 阅读1分钟
    {
  // Place your snippets for vue here. Each snippet is defined under a snippet name and has a prefix, body and
  // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
  // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
  // same ids are connected.
  // Example:

  "Print to console": {
    "prefix": "log",
    "body": [
      "console.log('$1')",
      "$2"
    ],
    "description": "Log output to console"
  },
  "Create VUE template": {
    "prefix": "v2",
    "body": [
      "<template>",
			"  <div>",
			"    $2",
      "  </div>",
      "</template>",
      "",
      "<script>",

      "export default {",
      "  name: '$1',",
      "  components: {",
      "  },",
      "  data() {",
      "    return {",
      "      $3",
      "    }",
      "  },",

      "}",
      "</script>",
      "",
      "<style scoped lang=\"scss\">",
      "  $4",
      "</style>"
    ],
    "description": "Create VUE template"
  },
  "Create VUE3 template": {
    "prefix": "v3",
    "body": [
      "<template>",
			"  <div>",
			"    $2",
			"  </div>",
			"</template>\n",
			"<script>",
			"import {defineComponent, reactive, toRefs} from 'vue'",
			"export default defineComponent({",
			"  name: '$1',",
			"  props: {\n",
			"  },",
			"  components: {\n",
			"  },",
			"  setup(){",
			"    const data = reactive({\n",
      "    })",
			"    return {",
			"        ...toRefs(data),",
			"    }",
			"  },",
			"})",
			"</script>\n",
			"<style scoped lang='scss'>\n",
			"</style>"
    ],
    "description": "Create VUE template"
  },
  "regEmail":{
    "prefix": "regEmail",
    "body": [
      "const regEmail = /^[a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/"
    ],
    "description": "regEmail components"
  },
  "regMobile":{
    "prefix": "regMobile",
    "body": [
      "const regMobile = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/"
    ],
    "description": "regMobile components"
  },
  "requiredfield":{
    "prefix": "requirefield",
    "body": [
      "{required: true, message: '请输入用户邮箱$1', trigger: 'blur'},"
    ],
    "description": "requiredfield components"
  }
}

`