Skip to content

Instantly share code, notes, and snippets.

@jovialcore
Last active April 29, 2024 11:13
Show Gist options
  • Save jovialcore/bfbd2873e6ff4db327f931243036a99a to your computer and use it in GitHub Desktop.
Save jovialcore/bfbd2873e6ff4db327f931243036a99a to your computer and use it in GitHub Desktop.
Number props tip in vuejs
<script setup>
//So in vuejs 3, to declare an integer prop, ideally, you should declare an object passing the prop as an object key and the expected dataype as value for that key
const props = defineProps({ totalPages : Number})
//another tip: when in the parent component, to pass the value for that integer prop, vuejs expects it to be a dynamic prop binding
</script>
<template>
<!--- inside parent component -->
<!--- e.g instead of this -->
<Pagination totalPages="4" />
<!--- it should be this -->
<Pagination :totalPages="4" />
<!--- take note of the colon `:` -->
to learn more: https://vuejs.org/guide/components/props.html#number
To see this in practice, take a look at how we implemented pagination for what-company-stack
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment