@babel/plugin-transform-exponentiation-operator(指数运算符转换插件)
非官方测试版翻译
本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →
信息
此插件已包含在 @babel/preset-env 中,属于 ES2016 规范的一部分
示例
输入
JavaScript
let x = 10 ** 2;
x **= 3;
输出
JavaScript
let x = Math.pow(10, 2);
x = Math.pow(x, 3);
安装
- npm
- Yarn
- pnpm
- Bun
npm install --save-dev @babel/plugin-transform-exponentiation-operator
yarn add --dev @babel/plugin-transform-exponentiation-operator
pnpm add --save-dev @babel/plugin-transform-exponentiation-operator
bun add --dev @babel/plugin-transform-exponentiation-operator
用法
通过配置文件(推荐)
babel.config.json
{
"plugins": ["@babel/plugin-transform-exponentiation-operator"]
}
通过命令行
Shell
babel --plugins @babel/plugin-transform-exponentiation-operator script.js
通过 Node API
JavaScript
require("@babel/core").transformSync("code", {
plugins: ["@babel/plugin-transform-exponentiation-operator"],
});