@ant-design-vue/babel-plugin-jsx
Babel plugin for Vue 3.0 JSX
Last updated 5 years ago by amour1688 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @ant-design-vue/babel-plugin-jsx 
SYNC missed versions from official npm registry.

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+

Current Tags

  • 1.0.0-alpha.2                                ...           alpha (5 years ago)
  • 1.0.0-alpha.5                                ...           beta (5 years ago)
  • 1.0.0-rc.1                                ...           latest (4 years ago)

11 Versions

  • 1.0.0-rc.1                                ...           4 years ago
  • 1.0.0-beta.4                                ...           4 years ago
  • 1.0.0-beta.3                                ...           4 years ago
  • 1.0.0-beta.2                                ...           4 years ago
  • 1.0.0-beta.1                                ...           4 years ago
  • 1.0.0-alpha.6                                ...           5 years ago
  • 1.0.0-alpha.5                                ...           5 years ago
  • 1.0.0-alpha.4                                ...           5 years ago
  • 1.0.0-alpha.3                                ...           5 years ago
  • 1.0.0-alpha.2                                ...           5 years ago
  • 1.0.0-alpha.1                                ...           5 years ago
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dev Dependencies (11)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE