Skip to content

Instantly share code, notes, and snippets.

@neodigm
Last active June 25, 2020 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neodigm/c9c4a455c0d7c3cd2565e62529f59efa to your computer and use it in GitHub Desktop.
Save neodigm/c9c4a455c0d7c3cd2565e62529f59efa to your computer and use it in GitHub Desktop.
<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>
@neodigm
Copy link
Author

neodigm commented May 24, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment