-
-
Save cursosdesarrolloweb/d161e123765dd7e57c633399c6ba76f6 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 () => ( | |
<> | |
<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