Created
April 1, 2023 15:13
-
-
Save johandanforth/27369a79767cede99f5d3fc35e704753 to your computer and use it in GitHub Desktop.
Sample browser-only use of vue.js version 3 page with vue-virtual-scroller
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
@page | |
@model PrivacyModel | |
@{ | |
Layout = null; | |
} | |
<html> | |
<head> | |
<title>vue virtual scroller sample</title> | |
<link href="https://unpkg.com/[email protected]/dist/vue-virtual-scroller.css" rel="stylesheet" /> | |
<style scoped> | |
.scroll-container { | |
height: 300px; | |
} | |
.scroller { | |
height: 100%; | |
} | |
.user { | |
height: 32%; | |
padding: 0 12px; | |
} | |
</style> | |
</head> | |
<body> | |
<h2>Virtual Scroller</h2> | |
<div id="app"> | |
<div class="scroll-container"> | |
<recycle-scroller class="scroller" | |
:items="list" | |
:item-size="32" | |
key-field="id" | |
v-slot="{ item }"> | |
<div class="user"> | |
{{ item.name }} | |
</div> | |
</recycle-scroller> | |
</div> | |
</div> | |
<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script> | |
<script src="https://unpkg.com/[email protected]/dist/vue-virtual-scroller.min.js"></script> | |
<script> | |
const { createApp } = Vue; | |
var app = createApp({ | |
data() { | |
return { | |
list: [] | |
} | |
}, | |
mounted() { | |
console.log("mounted"); | |
for (let i = 0; i < 10000; i++) { | |
this.list.push({ | |
id: i, | |
name: "item " + i | |
}); | |
} | |
} | |
}); | |
app.component('RecycleScroller', VueVirtualScroller.RecycleScroller); | |
app.mount('#app'); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment