VSCode自定义代码片段集合

HTML

指令为 html
{
  "Print to console": {
    // "scope": "javascript,typescript",
    "prefix": "html", //快捷键
    "body": [
      "<!DOCTYPE html>",
      "<html lang=\"en\">",
      "",
      "<head>",
      "  <meta charset=\"UTF-8\">",
      "  <meta name=\"viewport\"",
      "    content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,user-scalable=no\">",
      "  <title>page</title>",
      "  <link rel=\"stylesheet\" href=\"\">",
      "</head>",
      "<style>",
      "",
      "</style>",
      "",
      "<body>",
      "  <div class=\"\">",
      "  </div>",
      "</body>",
      "",
      "<script>",
      "</script>",
      "",
      "</html>"
    ],
    // "description": "Log output to console"
    "description": "vue html template"
  }
}

Vue

指令为 vue
{
  "Print to console": {
      "prefix": "vue",
      "body": [
          "<template>",
          "  <div class='$2'>$5</div>",
          "</template>",
          "",
          "<script>",
          "export default {",
          "  name: '',",
          "  components: {},",
          "  data() {",
          "    return {}",
          "  },",
          "  computed: {},",
          "  watch: {},",
          "  beforeCreate() {},",
          "  created() {},",
          "  beforeMount() {},",
          "  mounted() {},",
          "  methods: {},",
          "  beforeUpdate() {},",
          "  updated() {},",
          "  beforeDestroy() {},",
          "  destroyed() {}",
          "}",
          "</script>",
          "<style lang='scss'>",
          "$4",
          "</style>",
          "<style lang='scss' scoped>",
          "$4",
          "</style>"
      ],
      "description": "Log output to console"
  }
}

react

指令为 react-mobile
{
  "Import React": {
    "prefix": "react-mobile",
    "body": [
      "import React, { Component, useState, useEffect } from 'react'",
      "import { withRouter } from 'react-router-dom'\n",
      "import './index.css'\n",
      "import request from '../../utils/request'",
      "import APPMethod from '../../utils/appInteractive'\n",
      "class Page extends Component {",
      "  constructor(props) {",
      "    super(props)",
      "    this.state = {",
      "    }",
      "  }",
      "  componentDidMount(){",
      "  }",
      "  render () {",
      "    return (",
      "       <div className='page-wrap'>",
      "       </div>",
      "    )",
      "  }",
      "}\n",
      "export default Page\n",
      "\n",
      "//HOOK写法",
      "/*",
      "function Page() {",
      "  let [pageData, setPageData] = useState(null)",
      "  useEffect(()=>{",
      "  }, [])",
      "  return (",
      "    <div className='page-wrap'>",
      "      <div className='container'>",
      "      </div>",
      "    </div>",
      "  )",
      "}\n",
      "export default Page",
      "*/",

    ],
    "description": "引入React基本组件"
  },
  "Import PropTypes": {
    "prefix": "importproptypes",
    "body": [
      "import PropTypes from 'prop-types'"
    ],
    "description": "引入prop-types"
  },
  "Define defaultProps": {
    "prefix": "defaultProps",
    "body": [
      "static defaultProps = {",
      "  $1",
      "}\n"
    ]
  }
}

用户代码片段嘛,大概就这个样子,复制粘贴即可。
不同的代码片段只能在当下文件内才可以触发指令。
未来不定期更新其余代码片段。

如果转载,请标明地址,谢谢。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值