Skip to main content

@babel/plugin-transform-unicode-escapes

信息

此插件包含在 @babel/preset-env

¥This plugin is included in @babel/preset-env

编译 ES2015 Unicode 转义到 ES5

¥Compile ES2015 Unicode escapes to ES5

示例

¥Example

输入

¥In

JavaScript
var \u{1d49c} = "\u{Babe1}";

console.log(\u{1d49c});

输出

¥Out

JavaScript
var _ud835_udc9c = "\uDAAA\uDFE1";

console.log(_ud835_udc9c);

安装

¥Installation

npm install --save-dev @babel/plugin-transform-unicode-escapes

用法

¥Usage

¥With a configuration file (Recommended)

babel.config.json
{
"plugins": ["@babel/plugin-transform-unicode-escapes"]
}

通过 CLI

¥Via CLI

Shell
babel --plugins @babel/plugin-transform-unicode-escapes

通过 Node API

¥Via Node API

JavaScript
require("@babel/core").transformSync("code", {
plugins: ["@babel/plugin-transform-unicode-escapes"],
});