vscode设置vue代码片段,符合Eslint规范
vue默认代码片段提示很少,需要每次添加很多内容,。。。重点是输出的代码片段不符合Eslint规范,这就很烦,需要花时间去调格式,今天就花时间把vue代码片段提示改成符合Eslint规范,步骤如下:
1.点击[文件]-[首选项]-[用户片段]。
2.点击vue.json.我这里是修改,没有则新建一个
3.直接上代码,这个代码片段是我调过的,常用的方法,函数基本都写了,并且符合Eslint规范。
{
"vue-template": {
"prefix": "vue",
"body": [
"<template>",
" <div class='$0'>",
"",
" </div>",
"</template>",
"",
"<script>",
"export default {",
" name: '',",
" data () {",
" return {",
"",
" }",
" },",
" props: {",
"",
" },",
" components: {",
"",
" },",
" computed: {",
"",
" },",
" watch: {",
"",
" },",
" created () {",
"",
" },",
" mounted () {",
"",
" },",
" methods: {",
"",
" }",
"}",
"</script>",
"",
"<style scoped lang='less'>",
"</style>",
""
],
"description": "my vue template"
}
}
4.完美生成片段,没有Eslint报错。哈哈------这里的prefix设置唤醒语,$0用于片段生成后光标定位。