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

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

Vue 3.0 JSX 的 Babel 插件

中文使用文档
文档目录10 节
  1. 安装
  2. 使用量
  3. 选项
  4. 语法
  5. 内容
  6. 属性/ 道具
  7. 指令
  8. 槽
  9. 谁在用
  10. 兼容性

Vue 3.0 的 Babel 插件 JSX

test npm package

加入Vue JSX支持.

页:1 简体中文

安装

安装插件 :

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

然后将插件添加到.babelrc:

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

使用量

选项

打开

类型 : boolean

默认 : false

转换 on: { click: xx } 改为 onClick: xxx

优化

类型 : boolean

默认 : false

允许优化与否。 如果你对Vue 3不熟悉,不推荐启用.

海关元素

类型 : (tag: string) => boolean

默认 : undefined

配置自定义元素

语法

内容

职能构成部分

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

已生效

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>
  );
}

断裂

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

属性/ 道具

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

带有动态绑定的:

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

指令

v 显示

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

v 型号

注意: 您应该通过第二个参数作为字符串来使用 arg。 。 。 .

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

将汇编到:

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

自定义指令

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

槽

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

谁在用


蚂蚁设计Vue

范特语

兼容性

此 repo 仅兼容 :

  • 贝贝 7+
  • 第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 是什么?

Vue 3.0 JSX 的 Babel 插件

如何安装 @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 和提交记录判断。