VSCode 中 JSX 标签内的片段
Snippets within JSX tags in VSCode
如何在 JSX 标签中启用代码段完成以添加标签属性:
<View style={styles.styleName}>
我正在尝试让这个代码段起作用,但它似乎只在标签之外起作用:
"style": {
"scope": "javascript,typescript,jsx,html",
"prefix": "rs",
"body": ["style={ styles. }"],
"description": "RN style"
},
(未测试)如果您不反对使用键盘快捷键插入片段 - assign keybindings 可能有效。
VSCode 添加到 "javascriptreact" 中用于 jsx 文件。 (无需从市场安装任何东西)
例如,如果你想写一个获取快捷方式
{
"fetch": {
"scope": "javascriptreact,javascript",
"prefix": "fetch",
"body": [
"fetch('', {",
"\tmethod: '',",
"\tcredentials: 'same-origin',",
"\theaders: new Headers({",
"\t\t'X-CSRF-Token': this.state.form_token,"
"\t\t'Content-Type': 'application/json',",
"\t\t'Accept': 'application/json'",
"\t}),",
"\tbody: JSON.stringify(body)",
"\t}).then(res => res.json()).then(",
"\t(result) => {},",
"\t(error) => {}",
");"
]
}
}
将此添加到您的代码片段文件后,快捷方式就可以使用了。
解决原始问题。片段在 jsx 标签中工作
如何在 JSX 标签中启用代码段完成以添加标签属性:
<View style={styles.styleName}>
我正在尝试让这个代码段起作用,但它似乎只在标签之外起作用:
"style": {
"scope": "javascript,typescript,jsx,html",
"prefix": "rs",
"body": ["style={ styles. }"],
"description": "RN style"
},
(未测试)如果您不反对使用键盘快捷键插入片段 - assign keybindings 可能有效。
VSCode 添加到 "javascriptreact" 中用于 jsx 文件。 (无需从市场安装任何东西)
例如,如果你想写一个获取快捷方式
{
"fetch": {
"scope": "javascriptreact,javascript",
"prefix": "fetch",
"body": [
"fetch('', {",
"\tmethod: '',",
"\tcredentials: 'same-origin',",
"\theaders: new Headers({",
"\t\t'X-CSRF-Token': this.state.form_token,"
"\t\t'Content-Type': 'application/json',",
"\t\t'Accept': 'application/json'",
"\t}),",
"\tbody: JSON.stringify(body)",
"\t}).then(res => res.json()).then(",
"\t(result) => {},",
"\t(error) => {}",
");"
]
}
}
将此添加到您的代码片段文件后,快捷方式就可以使用了。
解决原始问题。片段在 jsx 标签中工作