WishMeLz

生活其实很有趣

VSCode自定义代码片段

"Vue Clone JSON": {    // 片段名字
	"prefix": "zclone",   //片段唤起关键字
	"body": [   //片段内的具体代码。需要全部使用”“引起来
	   "let ${2:clone} = JSON.parse(JSON.stringify($1))"
		]
	}

$1,$2  是光标的位置,有几个就出现几个位置,按TAB键切换。$2的写法就是会选中clone

"<script lang='tsx'>import { Component, Prop, Vue, Emit, Watch } from 'vue-property-decorator'",
			"@Component({})",
			"export default class ${1:add} extends Vue {render() {return (<div class='${1:add}'></div>)}}</script>",
			"<style lang='less' scoped></style>"

"<script lang='tsx'>",
			"import { getCurrentInstance, defineComponent, reactive } from 'vue'",
			"export default defineComponent({",
			"	name:'${1:pageName}',",
			"	setup(){",
				"		const currentInstance: any = getCurrentInstance();",
				"		const { $$service } = currentInstance.appContext.config.globalProperties",
				"		const $$router = currentInstance.proxy.$$root.$$router;",
				"		const route = currentInstance.proxy.$$route.redirectedFrom",
				"		return ()=>(",
				"			<div class='${1:pageName}'></div>",
				"		)",
				"	}",
				"})",
				"</script>",
				"<style lang='scss' scoped></style>"