云盘
志元云盘
备份云盘
Home
/
志元云盘
/
webdav
/
sync
/
c
/
vue-modbus
/
modbus-project
/
node_modules
/
@vue
/
babel-plugin-jsx
File
OriginalPic
Thumbnails
CopyAllDownloadUrl
EditTime
Size
dist
2024-07-23 07:18:03
69.09 KB
LICENSE
2024-07-14 16:19:05
1.04 KB
package.json
2024-07-14 16:19:05
1.35 KB
README.md
2024-07-14 16:19:05
6.31 KB
# Babel Plugin JSX for Vue 3 [](https://www.npmjs.com/package/@vue/babel-plugin-jsx) [](https://github.com/actions-cool/issues-helper) To add Vue JSX support. English | [简体中文](/packages/babel-plugin-jsx/README-zh_CN.md) ## Installation Install the plugin with: ```bash npm install @vue/babel-plugin-jsx -D ``` Then add the plugin to your babel config: ```json { "plugins": ["@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 #### mergeProps Type: `boolean` Default: `true` merge static and dynamic class / style attributes / onXXX handlers #### enableObjectSlots Type: `boolean` Default: `true` Whether to enable `object slots` (mentioned below the document) syntax". It might be useful in JSX, but it will add a lot of `_isSlot` condition expressions which increase your bundle size. And `v-slots` is still available even if `enableObjectSlots` is turned off. #### pragma Type: `string` Default: `createVNode` Replace the function used when compiling JSX expressions. ## Syntax ### Content functional component ```jsx const App = () =>
Vue 3.0
; ``` with render ```jsx const App = { render() { return
Vue 3.0
; }, }; ``` ```jsx import { withModifiers, defineComponent } from 'vue'; const App = defineComponent({ setup() { const count = ref(0); const inc = () => { count.value++; }; return () => (
{count.value}
); }, }); ``` Fragment ```jsx const App = () => ( <>
I'm
Fragment
> ); ``` ### Attributes / Props ```jsx const App = () =>
; ``` with a dynamic binding: ```jsx const placeholderText = 'email'; const App = () =>
; ``` ### Directives #### v-show ```jsx const App = { data() { return { visible: true }; }, render() { return
; }, }; ``` #### v-model > Note: You should pass the second param as string for using `arg`. ```jsx
``` ```jsx
``` ```jsx
``` ```jsx
``` Will compile to: ```js h(A, { argument: val, argumentModifiers: { modifier: true, }, 'onUpdate:argument': ($event) => (val = $event), }); ``` #### v-models (Not recommended since v1.1.0) > Note: You should pass a Two-dimensional Arrays to v-models. ```jsx
``` ```jsx
``` ```jsx
``` Will compile to: ```js h(A, { modelValue: foo, modelModifiers: { modifier: true, }, 'onUpdate:modelValue': ($event) => (foo = $event), bar: bar, barModifiers: { modifier: true, }, 'onUpdate:bar': ($event) => (bar = $event), }); ``` #### custom directive Recommended when using string arguments ```jsx const App = { directives: { custom: customDirective }, setup() { return () =>
; }, }; ``` ```jsx const App = { directives: { custom: customDirective }, setup() { return () =>
; }, }; ``` ### Slot > Note: In `jsx`, _`v-slot`_ should be replaced with **`v-slots`** ```jsx const A = (props, { slots }) => ( <>
{slots.default ? slots.default() : 'foo'}
{slots.bar?.()}
> ); const App = { setup() { const slots = { bar: () =>
B
, }; return () => (
A
); }, }; // or const App = { setup() { const slots = { default: () =>
A
, bar: () =>
B
, }; return () =>
; }, }; // or you can use object slots when `enableObjectSlots` is not false. const App = { setup() { return () => ( <>
{{ default: () =>
A
, bar: () =>
B
, }}
{() => 'foo'}
> ); }, }; ``` ### In TypeScript `tsconfig.json`: ```json { "compilerOptions": { "jsx": "preserve" } } ``` ## Who is using
Ant Design Vue
Vant
Element Plus
Vue Json Pretty
## Compatibility This repo is only compatible with: - **Babel 7+** - **Vue 3+**
2025-08-29 22:52:42 Friday 216.73.216.167 Runningtime:0.037s Mem:1.48 MB