每次新建.vue文件,可以利用VSCode的snippet在.vue
文件创建后能轻松地生成一套模板,
(偷懒促进技术发展,促进社会进步。。。。能用模板一键生成,绝对不去多敲一行代码,哈哈哈。。。)
步骤如下
- Ctrl + Shift + P打开控制台,输入
snippets
(首选项:配置用户代码片段); - 接下来输入
vue
并选择,VSCode会自动生成一个vue.json
的文件。这里就是我们要输入模板的地方了; - 根据原有注释掉的提示输入模板,具体格式如下(其中
$0
代表模板生成后,光标停留的位置):"Print to console":{ "prefix": "vue", "body": [ "<template>", " <div class=\"wrapper\">$0</div>", "</template>", "", "<script>", "export default {", " props: {", " },", " data () {", " return {", " }", " },", " created () {},", " mounted () {},", " watch: {},", " computed: {},", " methods: {},", " components: {},", "}", "</script>", "<style scoped>", "</style>" ], "description": "A vue file template" }
- 保存,重新启动vscode,新建.vue文件,在文件中输入vue即可看到提示,tab键即可生成原定义模板内容