我正在尝试为useState()
创建一个 VS 代码用户代码片段
目前我有
"use state": {
"prefix": "us",
"body": [
"const [$1, set${1/(.*)/${1:/upcase}/}] = useState($2);",
"$3"
],
"description": "creates use state"
},
当我以 $1(位置 1(输入"foo"时,我得到:
const [foo, setFOO] as useState()
但是我想得到:
const [foo, setFoo] as useState()
如何更改我的代码段以这种方式工作?
您只需要将变换更改为capitalize
,如下所示:
"const [$1, set${1/(.*)/${1:/capitalize}/}] = useState($2);",
您需要删除"*",此字符将所有其他字符转换为大写,没有它,您将只保留第一个大写字母。
"prefix": "us",
"body": [
"const [$1, set${1/(.)/${1:/upcase}/}] = useState($2);",
"$3"
],
"description": "creates use state"
},