-
-
Save cursosdesarrolloweb/3a4a79008abb27bced51ecd1049d80fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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 () => ( | |
<div> | |
<p>{count.value}</p> | |
<CounterButton text="Incrementar" onClicked={inc} /> | |
<CounterButton text="Decrementar" onClicked={dec} /> | |
</div> | |
); | |
}, | |
}); | |
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