bail- plugin- transform- jsx 类
支持带有指令的类名 .
示例
单位
import { createElement } from 'react';
export default function Foo(props) {
const { message } = props;
return (
<div x-class={['foo', {
bar: true,
active: false,
}]}>hello world</div>
);
}
出来
import { createElement } from 'react';
export default function Foo(props) {
const { message } = props;
return (
<div className={classnames(['foo', {
bar: true,
active: false,
}])}>hello world</div>
);
}
安装
$ npm install babel-plugin-transform-jsx-class
使用量
通过 .babelrc (建议)
.babelrc 图像
{
"plugins": ["transform-jsx-class"]
}
通过 CLI
$ babel --plugins transform-jsx-class script.js
节点 API
require("babel-core").transform("code", {
plugins: ["transform-jsx-class"]
});