Skip to content

Instantly share code, notes, and snippets.

@cursosdesarrolloweb
Created January 17, 2021 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cursosdesarrolloweb/d161e123765dd7e57c633399c6ba76f6 to your computer and use it in GitHub Desktop.
Save cursosdesarrolloweb/d161e123765dd7e57c633399c6ba76f6 to your computer and use it in GitHub Desktop.
<script type="text/jsx">
import { ref, reactive, watch, toRefs, defineComponent } from "vue";
const App = defineComponent({
setup() {
const count = ref(0);
const inc = () => {
count.value++;
};
const dec = () => {
count.value--;
};
return () => (
<>
<p>{count.value}</p>
<CounterButton text="Incrementar" onClicked={inc} />
<CounterButton text="Decrementar" onClicked={dec} />
</>
);
},
});
export default App
const CounterButton = defineComponent({
props: ["text"],
emits: ["clicked"],
setup(props, {emit}) {
return () => <button onClick={() => emit("clicked")}>{props.text}</button>
}
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment