-
Notifications
You must be signed in to change notification settings - Fork 1
/
stream.vue
45 lines (43 loc) · 1 KB
/
stream.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
<template>
<div style="justify-content:center">
<text class="label">Vue.js Github Star Count</text>
<text class="count">{{count}}</text>
</div>
</template>
<script>
const stream = weex.requireModule('stream')
export default {
data () {
return {
count: 'fetching...'
}
},
created () {
stream.fetch({
method: 'GET',
type: 'json',
url: 'https://api.github.com/repos/vuejs/vue'
}, res => {
if (res.ok) {
this.count = res.data.stargazers_count
} else {
this.count = '- unknown -'
}
})
}
}
</script>
<style scoped>
.label {
color: #666;
text-align: center;
font-size: 60px;
}
.count {
color: #41B883;
text-align: center;
font-size: 100px;
margin-top: 80px;
margin-bottom: 100px;
}
</style>