@ant-design-vue/babel-plugin-jsx

中文文档
1.0.0-rc.1发布于 2020/07/29MITCommonJS近 30 天下载 9197

Babel plugin for Vue 3.0 JSX

原始使用文档
文档目录10 节
  1. Installation
  2. Usage
  3. options
  4. Syntax
  5. Content
  6. Attributes / Props
  7. Directives
  8. Slot
  9. Who is using
  10. Compatibility

Babel Plugin JSX for Vue 3.0

test npm package

To add Vue JSX support.

English | 简体中文

Installation

Install the plugin with:

npm install @ant-design-vue/babel-plugin-jsx -D

Then add the plugin to .babelrc:

{
  "plugins": ["@ant-design-vue/babel-plugin-jsx"]
}

Usage

options

transformOn

Type: boolean

Default: false

transform on: { click: xx } to onClick: xxx

optimize

Type: boolean

Default: false

enable optimization or not. It's not recommended to enable it If you are not familiar with Vue 3.

isCustomElement

Type: (tag: string) => boolean

Default: undefined

configuring custom elements

Syntax

Content

functional component

const App = () => <div></div>;

with render

const App = {
  render() {
    return <div>Vue 3.0</div>;
  }
};
const App = defineComponent(() => {
  const count = ref(0);

  const inc = () => {
    count.value++;
  };

  return () => (
    <div onClick={inc}>
      {count.value}
    </div>
  );
});
import { withModifiers } from 'vue';

const App = () => {
  const count = ref(0);

  const inc = () => {
    count.value++;
  };

  return () => (
    <div onClick={withModifiers(inc, ['self'])}>
      {count.value}
    </div>
  );
}

Fragment

const App = () => (
  <>
    <span>I'm</span>
    <span>Fragment</span>
  </>
);

Attributes / Props

const App = () => <input type="email" />;

with a dynamic binding:

const placeholderText = 'email';
const App = () => (
  <input
    type="email"
    placeholder={placeholderText}
  />
);

Directives

v-show

const App = {
  data() {
    return { visible: true };
  },
  render() {
    return <input v-show={this.visible} />;
  },
};

v-model

Note: You should pass the second param as string for using arg.

<input v-model={val} />
<input v-model={[val, ['trim']]} />
<A v-model={[val, 'foo', ['bar']]} />

Will compile to:

h(A, {
  'foo': val,
  "fooModifiers": {
    "bar": true
  },
  "onUpdate:foo": $event => val = $event
})

custom directive

const App = {
  directives: { custom: customDirective },
  setup() {
    return () => (
      <a
        v-custom={[val, 'arg', ['a', 'b']]}
      />
    );
  },
};

Slot

const App = {
  setup() {
    const slots = {
      default: () => <div>A</div>,
      foo: () => <span>B</span>
    };
    return () => <A v-slots={slots} />;
  }
};

Who is using


Ant Design Vue

Vant

Compatibility

This repo is only compatible with:

  • Babel 7+
  • Vue 3+

版本与发布记录

@ant-design-vue/babel-plugin-jsx 共发布 12 个版本,首次发布于 2020/05/24;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.0-rc.1latest2020/07/296 年前
1.0.0-beta.42020/07/226 年前
1.0.0-beta.32020/07/156 年前
1.0.0-beta.22020/07/156 年前
1.0.0-beta.12020/07/126 年前
1.0.0-alpha.62020/06/216 年前

其他发布通道:alpha → 1.0.0-alpha.2,beta → 1.0.0-alpha.5。

关于 @ant-design-vue/babel-plugin-jsx 的常见问题

@ant-design-vue/babel-plugin-jsx 是什么?

Babel plugin for Vue 3.0 JSX

如何安装 @ant-design-vue/babel-plugin-jsx?

在项目目录运行 npm install @ant-design-vue/babel-plugin-jsx,或使用 pnpm add / yarn add / bun add。

@ant-design-vue/babel-plugin-jsx 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/ant-design-vue__babel-plugin-jsx 是否存在。

@ant-design-vue/babel-plugin-jsx 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@ant-design-vue/babel-plugin-jsx 可以商用吗?

@ant-design-vue/babel-plugin-jsx 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ant-design-vue/babel-plugin-jsx 的下载量有多少?

根据 npm 官方下载统计,@ant-design-vue/babel-plugin-jsx 在 2026/10/06 – 2026/11/04 这 30 天内被下载 9,197 次,日均约 307 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ant-design-vue/babel-plugin-jsx 还在维护吗?

最新版本 1.0.0-rc.1 发布于 2020/07/29(6 年前);至今共发布 12 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/05/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。