vscode 通过模板创建文件

1、设置 进入 用户首选项

2、在下面页面输入vue

进入 vue.json 模板设置页面

输入以下代码


{
    // vue2模板
    "Print to console" : {
        "prefix" : "zs" ,
        "body" : [
            "<template>" ,
            "  <div class= \" $1 \" >$2</div>" ,
            "</template>" ,
            "" ,
            "<script>" ,
            "export default {" ,
            "  components: {$3}," ,
            "  data () {" ,
            "    return {" ,
            "$4" ,
            "    }" ,
            "  }," ,
            "  methods: {}," ,
            "  created () {}" ,
            "}" ,
            "</script>" ,
            "<style lang= \" less \" scoped>" ,
            "</style>" ,
            "" ,
        ],
        "description" : "A vue file template"
    },
    // vue3语法糖模板
    "Print to setup" : {
        "prefix" : "setup" ,
        "body" : [
            "<template>" ,
            "  <div></div>" ,
            "</template>" ,
            "<script lang='ts' setup> \n " ,
            "</script>" ,
            "<style scoped> \n " ,
            "</style>" ,
        ],
        "description" : "Log output to console"
    }
}
4、新建vue文件
setup 在vue.json 文件中输入的  "prefix" : "setup" , 可以根据自己喜好自行设置
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章