常用snippets

背景

基于 vscode ,提高开发效率

添加路径

File >> Preferences >> User Snippets >> New Snippets

vue模板

{
  // 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"
  // }
  "vue": {
    "prefix": "vue",
    "body": [
      "<template>",
        "  <view class=\"container\">",
        "  </view>",
      "</template>",
      "",
      "<script>",
      "import { config, util, api } from '../../utils/index'",
      "export default {",
        "  components: {},",
        "  computed: {",
        "    // test: {",
        "    //   get: function () {},",
        "    //   set: function (v) {}",
        "    // }",
        "  },",
        "  watch: {",
        "    // test: function (newObj, oldObj) {}",
        "  },",
        "  data () {",
          "    return {",
            "      staticHost: config.staticHost,",
            "      defaultImg: config.defaultImg,",
            "      assets: config.defaultImg.assets,",
            "      dataList: [],",
            "      resData: {},",
            "      dataLoading: false",
          "    }",
        "  },",
        "  beforeCreate () {},",
        "  created () {},",
        "  beforeMount () {},",
        "  mounted () {},",
        "  beforeDestroy () {},",
        "  destroyed () {},",
        "  onLoad (op) {},",
        "  onShow () {},",
        "  onReady () {},",
        "  // 用户点击右上角分享",
        "  onShareAppMessage: function (res) {",
          "    const that = this",
          "    if (res.from === 'button') {",
            "      const shareMsg = util.getShareObj(that)",
            "      return util.commonShareAppMessage(shareMsg)",
          "    } else {",
            "      return util.commonShareAppMessage()",
          "    }",
        "  },",
        "  onPullDownRefresh () {},",
        "  onReachBottom () {},",
        "  methods: {}",
      "}",
      "</script>",
      "",
      "<style lang='scss' scoped>",
      ".container {",
        "  background: #f7f8fa;",
      "}",
      "</style>",
      "",
    ]
  }
}

uniVue模板

component

api.js

request

initStorage

judgeAll

setStorage

image

staticHostImg

formatDate

initSelections

iconfont

initLinkAndTitle

onShow

getParams

goto

getPrePage

getList

uniUpload

promise

Last updated

Was this helpful?