Skip to content

Commit b313a0f

Browse files
committed
Update demos.
1 parent c6596b6 commit b313a0f

File tree

8 files changed

+34
-16
lines changed

8 files changed

+34
-16
lines changed

demos/common/Item.vue

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<div class="item" v-bind:style="itemStyle">
33
<div class="index">#{{ index }}</div>
44
<div class="card">
5-
<div class="card-avatar">
6-
{{ info.name.substr(0, 2) }}
7-
<!-- <img class="card-avatar-img" v-bind:src="info.avatar" alt="AVATAR"> -->
5+
<div class="card-avatar" v-bind:class="{'no-avatar': !avatar}">
6+
<span v-if="!avatar">{{ info.name.substr(0, 2) }}</span>
7+
<img v-else class="card-avatar-img" v-bind:src="info.avatar" alt="AVATAR">
88
</div>
99
<div class="card-info">
1010
<div class="card-info-item name">Name: {{ info.name }}</div>
@@ -16,6 +16,8 @@
1616
</template>
1717

1818
<script>
19+
import { getQuery } from './util'
20+
1921
export default {
2022
name: 'item',
2123
@@ -29,6 +31,12 @@ export default {
2931
}
3032
},
3133
34+
data () {
35+
return {
36+
avatar: getQuery('avatar') !== null
37+
}
38+
},
39+
3240
computed: {
3341
itemStyle () {
3442
return {
@@ -62,11 +70,15 @@ export default {
6270
&-avatar {
6371
width: 40px;
6472
height: 40px;
65-
background: #ff6347;
73+
background: #efefef;
74+
color: #4169e1;
6675
border-radius: 50%;
6776
text-align: center;
6877
line-height: 40px;
69-
color: #ffffff;
78+
&.no-avatar {
79+
background: #ff6347;
80+
color: #ffffff;
81+
}
7082
&-img {
7183
display: block;
7284
width: 100%;

demos/common/util.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ export const getRandomUser = () => {
99
// avatar: `https://getavataaars.com/?hairColor=BrownDark&topType=LongHairStraight2`
1010
}
1111
}
12+
13+
export const getQuery = (query) => {
14+
try {
15+
return new URLSearchParams(window.location.search).get(query)
16+
} catch (e) {
17+
return false
18+
}
19+
}

demos/item-mode/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="container">
55
<header>
66
<h1>item-mode</h1>
7-
<p>Use this mode can save a considerable amount of memory and performance.</p>
7+
<p>Use vNode to build item list.</p>
88
</header>
99
<div class="main">
1010
<virtual-list class="list"

demos/item-mode/build.js

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demos/frag-mode/App.vue renamed to demos/vfor-mode/App.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
22
<div class="app">
3-
<GithubCorner path="/frag-mode" />
3+
<GithubCorner path="/vfor-mode" />
44
<div class="container">
55
<header>
6-
<h1>frag-mode</h1>
7-
<p></p>
6+
<h1>vfor-mode</h1>
7+
<p>Use v-for to build item list.</p>
88
</header>
99
<div class="main">
1010
<virtual-list class="list"
@@ -31,7 +31,7 @@ import { getRandomUser } from '../common/util'
3131
3232
const remain = 6
3333
const itemSize = 80
34-
const itemCount = 1000 * 10
34+
const itemCount = 1000 * 100
3535
3636
let itemList = []
3737
for (let idx = 0; idx < itemCount; idx++) {

demos/frag-mode/build.js renamed to demos/vfor-mode/build.js

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)