vsCode设置代码片段-LMLPHP

输入vue.json

{
"Print to console": { "prefix": "vv", "body": [ "<template>", " <div>$0</div>", "</template>", "", "<script>", "export default {",
"",
" components: {",
"",
" },",
"",
" data() {",
" return {",
" ",
" }",
" },",
"",
" created() {",
"",
" },",
"",
"",
" mounted() {",
" this.onLoad()",
" },",
"",
" methods: {",
" onLoad() {}",
" }",
"",
"}", "", "</script>", "<style lang=\"scss\">",
"",
"</style>", "",
], "description": "Log output to console"
}
}

字段注释

prefix :这个参数是使用代码段的快捷入口,比如这里的log在使用时输入log会有智能感知.
body :这个是代码段的主体.需要设置的代码放在这里,字符串间换行的话使用 \r\n换行符隔开.注意如果值里包含特殊字符需要进行转义.
$1 :这个为光标的所在位置.
$2 :使用这个参数后会光标的下一位置将会另起一行,按tab键可进行快速切换
description :代码段描述,在使用智能感知时的描述
05-26 05:33