Created
April 29, 2021 15:20
-
-
Save daikiojm/6479c82859bd8ce4971ba11469203c51 to your computer and use it in GitHub Desktop.
party.js with vue sfc component
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
<template> | |
<div class="container"> | |
<button | |
ref="buttonRef" | |
href="#" | |
class="button--green" | |
@click.prevent="handleClick" | |
> | |
party | |
</button> | |
</div> | |
</template> | |
<script lang="ts"> | |
import { defineComponent, ref } from '@nuxtjs/composition-api' | |
import * as party from 'party-js' | |
export default defineComponent({ | |
setup() { | |
const buttonRef = ref<HTMLButtonElement>() | |
const handleClick = () => { | |
party.confetti(buttonRef.value!) | |
} | |
return { | |
handleClick, | |
buttonRef, | |
} | |
}, | |
}) | |
</script> | |
<style> | |
.container { | |
margin: 0 auto; | |
min-height: 100vh; | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
text-align: center; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment