Last active
June 25, 2020 19:31
-
-
Save neodigm/c9c4a455c0d7c3cd2565e62529f59efa to your computer and use it in GitHub Desktop.
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> | |
<v-fragment> | |
<ul v-if="items.length > 0"> | |
<li v-for="(item, index) in items" :key="index">{{ item.title }}</li> | |
</ul> | |
<button v-on:click="fetchMore">Fetch More</button> | |
</v-fragment> | |
</template> | |
<script> | |
import { ref, computed, onMounted } from "vue"; | |
export default { | |
setup(props) { | |
onMounted(() => console.log("component mounted!")); | |
const items = ref([{ title: "Item 1" }, { title: "Item 2" }]); | |
const fetchMore = () => { | |
items.value = [...items.value, { title: "Fetched item" }]; | |
}; | |
return { | |
items, | |
fetchMore | |
}; | |
} | |
}; | |
</script> | |
<style scoped></style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Documentation:
https://www.vuemastery.com/pdf/Vue-3-Cheat-Sheet.pdf