refactor: support transformOn

This commit is contained in:
Amour1688
2020-05-26 21:04:56 +08:00
parent 402568dc52
commit 7a1a39a4cb
19 changed files with 161 additions and 95 deletions

View 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');