Vscode创建自定义代码模板(eg:xxx.jsx)[javascriptreact.json]

Vscode创建自定义代码模板(eg:xxx.jsx)[javascriptreact.json]_第1张图片
Vscode创建自定义代码模板(eg:xxx.jsx)[javascriptreact.json]_第2张图片

{
	// Place your snippets for javascriptreact here. Each snippet is defined under a snippet name and has a prefix, body and 
	// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
	// same ids are connected.
	// Example:
	// "Print to console": {
	// 	"prefix": "log",
	// 	"body": [
	// 		"console.log('$1');",
	// 		"$2"
	// 	],
	// 	"description": "Log output to console"
	// }
	"React-JSX(Function)": {
		"prefix": "jsx-f",
		"body": [
			"import React from \"react\";\n",
			"const $1 = (props) => {\n",
			"  return (\n",
			"  );",
			"};\n",
			"export default $1;"
		],
		"description": "JSX模板-Function"
	},
	"React-JSX(Class)": {
		"prefix": "jsx-c",
		"body": [
			"import React, {Component} from \"react\";\n",
			"class $1 extends React.Component {",
			"  constructor(props) {",
			"    super(props);",
			"    this.state = {};",
			"  }\n",
			"  render() {",
			"    return ();",
			"  }",
			"}\n",
			"export default $1;"
		],
		"description": "JSX模板-Class"
	},
	"React-JSX(Class-Form)": {
		"prefix": "jsx-c-form",
		"body": [
			"import React, {Component} from \"react\";\n",
			"class $1 extends React.Component {",
			"  constructor(props) {",
			"    super(props);",
			"    this.state = {};",
			"  }\n",
			"  handleChange = (event) => {",
			"    this.setState({});",
			"  };\n",
			"  handleSubmit = (event) => {",
			"    event.preventDefault();",
			"  };\n",
			"  render() {",
			"    return ();",
			"  }",
			"}\n",
			"export default $1;"
		],
		"description": "JSX模板-Class-Form"
	},
}

你可能感兴趣的:(V3)