Vue
by MoruoFrog
HTML
<div id="app">
<p>It's {{ firstUser.name }}'s show time</p>
<div>total: {{ total }}</div>
</div>
Vue
const user = []
let i = 0
while (i++ < 50000) {
user.push(`kun_${i}`, i)
}
new Vue({
el: "#app",
data() {
return {
originSserList: user,
}
},
computed: {
firstUser() {
const userList = this.userList
return userList.length ? userList[0] : {}
},
total() {
return this.userList.length
},
userList() {
const result = []
const user = this.originSserList
for(let i = 0; i < user.length; i += 2) {
const name = user[i]
const id = user[i + 1]
result.push({ name, id })
}
return result
},
},
})