@babel/plugin-transform-react-jsx-self
示例
🌐 Example
在
<sometag />
出
<sometag __self={this} />
安装
🌐 Installation
- npm
- Yarn
- pnpm
- Bun
npm install --save-dev @babel/plugin-transform-react-jsx-self
yarn add --dev @babel/plugin-transform-react-jsx-self
pnpm add --save-dev @babel/plugin-transform-react-jsx-self
bun add --dev @babel/plugin-transform-react-jsx-self
用法
🌐 Usage
使用配置文件(推荐)
🌐 With a configuration file (Recommended)
babel.config.json
{
"plugins": ["@babel/plugin-transform-react-jsx-self"]
}
通过 CLI
🌐 Via CLI
Shell
babel --plugins @babel/plugin-transform-react-jsx-self script.js
通过 Node API
🌐 Via Node API
JavaScript
require("@babel/core").transformSync("code", {
plugins: ["@babel/plugin-transform-react-jsx-self"],
});