Skip to content

Instantly share code, notes, and snippets.

@cursosdesarrolloweb
Last active January 17, 2021 10:02
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/3a4a79008abb27bced51ecd1049d80fe to your computer and use it in GitHub Desktop.
Save cursosdesarrolloweb/3a4a79008abb27bced51ecd1049d80fe 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 () => (
<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