-
Notifications
You must be signed in to change notification settings - Fork 6
/
ExampleMasonry.vue
69 lines (62 loc) · 1.78 KB
/
ExampleMasonry.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<template>
<section>
<h1 class="mb-24">Vue Masonry Wall</h1>
<vue-masonry-wall :items="items" :options="options" @append="append">
<template v-slot:default="{item}">
<div class="p-16-24 border-3 bg-steam">
<h5>{{item.title}}</h5>
<p class="text-ellipsis">{{item.content}}</p>
</div>
</template>
</vue-masonry-wall>
</section>
</template>
<script>
import VueMasonryWall from "vue-masonry-wall";
function content() {
const length = Math.random() * 300 + 30
let result = '';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const charactersLength = characters.length;
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
export default {
name: "ExampleMasonry",
components: {VueMasonryWall},
data() {
return {
options: {
width: 300,
padding: {
2: 8,
default: 12
},
},
items: [
{title: 'Item 0', content: content()},
{title: 'Item 1', content: content()},
{title: 'Item 2', content: content()},
{title: 'Item 3', content: content()},
{title: 'Item 4', content: content()},
{title: 'Item 5', content: content()},
{title: 'Item 6', content: content()},
{title: 'Item 7', content: content()},
{title: 'Item 8', content: content()},
{title: 'Item 9', content: content()},
]
}
},
methods: {
append() {
for (let i = 0; i < 20; i++) {
this.items.push({title: `Item ${this.items.length}`, content: content()})
}
}
}
}
</script>
<style scoped>
</style>