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