Skip to content

Instantly share code, notes, and snippets.

@jakenuts
Created May 6, 2023 03:00
Show Gist options
  • Save jakenuts/4553e437fcc5e9737e0b270d9a9cbc19 to your computer and use it in GitHub Desktop.
Save jakenuts/4553e437fcc5e9737e0b270d9a9cbc19 to your computer and use it in GitHub Desktop.
Code Templates
<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