vs code react基本代码块

/**
 * @description: 项目代码片段 类似于快捷键
 */

 {
    "打印": {
      "prefix": "cl",
      "body": ["console.log('$1');"]
    },
    "从react中引入useState": {
      "prefix": "isr",
      "body": ["import { useState } from 'react'"]
    },
    "从react中引入useEffect": {
      "prefix": "ier",
      "body": ["import { useEffect } from 'react'"]
    },
    "从react中引入useState,useEffect": {
      "prefix": "iser",
      "body": ["import { useState,useEffect } from 'react'"]
    },
    "从react中引入hooks": {
      "prefix": "ir",
      "body": ["import { $1 } from 'react'"]
    },
    "快捷生成hooks页面模板": {
      "prefix": "ptpl",
      "body": [
        "import React, { $1 } from 'react'",
        "import { View } from '@tarojs/components'",
        "import styles from './index.module.scss'",
        "\nconst $3 = () => {",
        "\t$4",
        "\treturn (",
        "\t\t<View className={$5}>",
        "$6",
        "\t\t</View>",
        "\t)",
        "}",
        "export default $3"
      ]
    },
    "快捷生成hooks组件模板": {
      "prefix": "ctpl",
      "body": [
        "import React, { $1 } from 'react'",
        "import { View } from '@tarojs/components'",
        "import styles from './index.module.scss'",
        "\nconst $2 = () => {",
        "\t$3",
        "\treturn (",
        "\t\t<View className={$4}>",
        "$5",
        "\t\t</View>",
        "\t)",
        "}",
        "export default $2"
      ]
    },
    "从componens中引入": {
      "prefix": "components",
      "body": ["import $1 from '@/components/$2'"]
    },
    "从pages中引入": {
      "prefix": "pages",
      "body": ["import $1 from '@/pages/$2'"]
    },
    "从config中引入": {
      "prefix": "config",
      "body": ["import { $1 } from '@/config/$2'"]
    },
    "从images中引入": {
      "prefix": "images",
      "body": ["import $1 from '@/images/$2'"]
    },
    "从model中引入": {
      "prefix": "model",
      "body": ["import $1 from '@/model/$2'"]
    },
    "从styles中引入": {
      "prefix": "css",
      "body": ["import $1 from '@/styles/$2'"]
    },
    "从utils中引入": {
      "prefix": "utils",
      "body": ["import $1 from '@/utils'"]
    },
    "ts注释快捷代码块": {
      "prefix": "/",
      "body": ["/** $1 */"]
    },
    "导入ts默认接口": {
      "prefix": "edi",
      "body": ["// $1", "export default interface $2 {", "\t/** $3 */", "\t$4", "}"]
    },
    "导入Ts接口": {
      "prefix": "ei",
      "body": ["// $1", "export interface $2 {", "\t/** $3 */", "\t$4", "}"]
    },
    "导入默认Function": {
      "prefix": "edf",
      "body": ["/**", "* @params: $3", "* @return: $4", "* @description: $5", "*/", "export const $1 = (): $6 => {", "\t$7", "}", "\n", "export default $1"]
    },
    "导入Function": {
      "prefix": "ef",
      "body": ["/**", "* @params: $3", "* @return: $4", "* @description: $5 ", "*/", "export const $1 = (): $6 => {", "\t$7", "}"]
    },
    "声明方法注释": {
      "prefix": "fdesc",
      "body": ["/**", "* @info: $1 for $2 at $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND", "* @params: $3", "* @return: $4", "* @description: $5 ", "*/"]
    },
    "生成es6自定义函数": {
      "prefix": "cf",
      "body": ["// $1", "const $2 = ($3): $4 => {", "\t$5", "}"]
    },
    "声明useState数据": {
      "prefix": "us",
      "body": ["// $1", "const [$2] = useState<$3>($4)"]
    },
    "声明useEffect数据": {
      "prefix": "ue",
      "body": ["// $1", "useEffect(() => {)", "\t$3", "\treturn () => $4", "}, [$2])"]
    },
    "声明文件作用": {
      "prefix": "fd",
      "body": [
        "/**",
        "* @Author: $1",
        "* @Date: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
        "* @LastEditors: $1",
        "* @LastEditTime: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
        "* @Description: $2",
        "* @Rules: $3",
        "*/"
      ]
    },
    "声明组件作用": {
      "prefix": "desc",
      "body": ["/**", "* @Author: $1", "* @Tbnumber: $3", "* @Url: $4", "* @Description: $2", "*/"]
    }
  }
  

 

posted @ 2021-09-24 15:35  simple-love  阅读(316)  评论(0)    收藏  举报