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" , 可以根據自己喜好自行設置
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章