mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2025-08-16 20:23:20 +08:00
refactor: support transformOn
This commit is contained in:
53
packages/babel-plugin-jsx/example/index.js
Normal file
53
packages/babel-plugin-jsx/example/index.js
Normal file
@ -0,0 +1,53 @@
|
||||
import { createApp, ref, defineComponent } from 'vue';
|
||||
|
||||
const SuperButton = (props, context) => {
|
||||
const obj = {
|
||||
mouseover: () => {
|
||||
context.emit('mouseover');
|
||||
},
|
||||
click: () => {
|
||||
context.emit('click');
|
||||
},
|
||||
};
|
||||
return (
|
||||
<div class={props.class}>
|
||||
Super
|
||||
<button
|
||||
on={obj}
|
||||
>
|
||||
{ props.buttonText }
|
||||
{context.slots.default()}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
SuperButton.inheritAttrs = false;
|
||||
|
||||
const App = defineComponent(() => {
|
||||
const count = ref(0);
|
||||
const inc = () => {
|
||||
count.value++;
|
||||
};
|
||||
|
||||
const obj = {
|
||||
click: inc,
|
||||
mouseover: inc,
|
||||
};
|
||||
|
||||
return () => (
|
||||
<div>
|
||||
Foo {count.value}
|
||||
<SuperButton
|
||||
buttonText="VueComponent"
|
||||
class="xxx"
|
||||
vShow={true}
|
||||
on={obj}
|
||||
>
|
||||
<button>1234</button>
|
||||
</SuperButton>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
createApp(App).mount('#app');
|
Reference in New Issue
Block a user