Created
May 6, 2023 03:00
-
-
Save jakenuts/4553e437fcc5e9737e0b270d9a9cbc19 to your computer and use it in GitHub Desktop.
Code Templates
This file contains hidden or 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
<template> | |
<div ref="fooDiv" @click="onClicked">Hello {{ counter }} Clicks</div> | |
</template> | |
<script setup lang="ts" > | |
import { defineProps, ref, onMounted } from 'vue'; | |
const props = defineProps<{ foo?: number }>(); | |
const emit = defineEmits<{ (e: 'update:clicks', clicks: number): void }>(); | |
const counter = ref<number>(props.foo ?? 0); | |
const onClicked = () => { emit("update:clicks", ++counter.value); } | |
onMounted(() => { | |
console.info(`[hello-component] mounted ${props.foo}`); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment