Ctrl + Shift + P > 输入snippets > 首选项 > 用户代码片断 > 新建全局代码片段文件 > 输入文件名
复制下面代码片段(按照个人习惯进行调整)
{
// Example:
"Print to console": {
"prefix": "vueinit", //快捷输入命名
"body": [
"<template>",
" <div class=\"wrapper\">",
"",
" </div>",
"</template>",
"",
"<script>",
"//import xxx from 'xxx' ",
"export default {",
" components: {},",
" props: {},",
" data() {",
" return {",
"",
" };",
" },",
" created() {},",
" mounted() {",
"",
" },",
" methods: {",
"",
" },",
"};",
"</script>",
"<style lang=\"less\" scoped>",
".wrapper{",
"",
"}",
"</style>"
],
"description": "A vue file template"
}
}
重启vscode就可以了
el-dialog 模版
{
// Example:
"Print to console": {
"prefix": "el-dialog", //快捷输入命名
"body": [
"<template>",
" <div class=\"wrapper wrapper_form_center\">",
" <el-dialog",
" :visible.sync=\"isShow\"",
" :close-on-click-modal=\"false\"",
" :close-on-press-escape=\"false\"",
" :before-close=\"close\"",
" width=\"560px\"",
" >",
" <div slot=\"title\">个人资料</div>",
" <div class=\"content\">",
" <el-form :model=\"ruleForm\" :rules=\"rules\" ref=\"ruleForm\" label-width=\"100px\">",
" <el-form-item label=\"角色名:\" prop=\"roleName\">",
" <el-input placeholder=\"请输入角色名\" v-model=\"ruleForm.roleName\"></el-input>",
" </el-form-item>",
" </el-form>",
" </div>",
" <div slot=\"footer\">",
" <btn-comp @click=\"close\">取消</btn-comp>",
" <btn-comp @click=\"submit()\">确定</btn-comp>",
" </div>",
" </el-dialog>",
" </div>",
"</template>",
"",
"<script>",
"//import xxx from 'xxx'",
"export default {",
" components: {},",
" props: {",
" isShow: {",
" type: Boolean,",
" default: false",
" }",
" },",
" data() {",
" return {",
" ruleForm: {",
" roleName: \"\" ",
" },",
" rules: {}",
" };",
" },",
" created() {},",
" mounted() {},",
" methods: {",
" close() {",
" this.$refs[\"ruleForm\"].resetFields();",
" this.$emit(\"close\");",
" },",
" submit() {",
" this.$refs.ruleForm.validate(async valid => {",
" if (valid) {",
"",
" }",
" });",
" }",
" }",
"};",
"</script>",
"<style lang=\"scss\" scoped>",
" .wrapper {",
"",
" }",
"</style>",
],
"description": "A vue file template"
}
}