vue 模板封装
方法:
打开 VSCODE 编辑器,依次选择“文件 -> 首选项 -> 用户代码片段”,此时,会弹出一个搜索框,我们输入vue, 如下:
选择 vue 后,VSCODE会自动打开一个名字为vue.json 的文件,复制以下内容到这个文件中:
{
"Print to console": {
"prefix": "vue",
"body": [
"<template>",
" <div class='vue'>vue模板</div>",
"</template>",
"",
"<script>",
"export default {",
" components: {},",
"",
" data () {",
" return {",
" };",
" },",
"",
" computed: {},",
"",
" created() {},",
"",
" mounted() {},",
"",
" methods: {}",
"}",
"",
"</script>",
"<style lang='scss' scoped>",
"</style>"
],
"description": "Log output to console"
}
}
保存后关闭这个文件。
例如:我们新建一个名为 header.vue 的文件,输入 vue 按下 enter,就会自动生成内容(此处应该有截图):
如下图