在VSCode中生成Vuex Getter Setter的方法

问题描述

有没有一种方法可以轻松地在VSCode(Visual Studio代码)中生成带有计算属性的vuex Getter和Setter?

解决方法

这是在计算属性中生成Vuex Getter和Setter的方法。

我使用VSCode代码段。这是代码段:

{
"Vuex Getter and Setter ": {
    "scope": "javascript,typescript,vue","prefix": "gset","body": [
        "${2:property}: {","\tget() {","\t\treturn this.\\$store.state.${1:objet}.${2:property}","\t},","\tset(value) {","\t\tthis.\\$store.commit('update${1/^(.)(.*)/${1:/upcase}${2}/}${2/^(.)(.*)/${1:/upcase}${2}/}',value)","\t}","}"
    ],"description": "Generate vuex getter and setter for an object and a property"
}

}

这里是结果:

result

如果您知道更好的方法,或者很酷的VSCode插件做到这一点,我将很高兴学习