- Vue.js 2 Web Development Projects
- Guillaume Chau
- 101字
- 2021-07-02 22:34:35
The 'last play' overlay
This one is a bit more complex. We need a new function to get the last played card by a player. In the utils.js file, add the new getLastPlayedCard function:
function getLastPlayedCard (player) {
return cards[player.lastPlayedCardId]
}
We can now use this function in a lastPlayedCard computed property by passing the opponent prop:
Vue.component('overlay-content-last-play', {
template: `<p>
<p v-if="opponent.skippedTurn">{{ opponent.name }} turn was skipped!</p>
<template v-else>
<p>{{ opponent.name }} just played:</p>
<card :def="lastPlayedCard" />
</template>
</p>`,
props: ['opponent'],
computed: {
lastPlayedCard () {
return getLastPlayedCard(this.opponent)
},
},
})
Note that we are directly reusing the card component we made earlier to display the card.
推薦閱讀
- Facebook Application Development with Graph API Cookbook
- Java完全自學(xué)教程
- Python數(shù)據(jù)分析基礎(chǔ)
- Visual Basic程序開發(fā)(學(xué)習(xí)筆記)
- Hands-On Image Processing with Python
- Learning C++ Functional Programming
- Python Deep Learning
- 基于Java技術(shù)的Web應(yīng)用開發(fā)
- Mastering C++ Multithreading
- Access 2010數(shù)據(jù)庫(kù)應(yīng)用技術(shù)實(shí)驗(yàn)指導(dǎo)與習(xí)題選解(第2版)
- 硬件產(chǎn)品設(shè)計(jì)與開發(fā):從原型到交付
- MySQL 8從零開始學(xué)(視頻教學(xué)版)
- 官方 Scratch 3.0 編程趣味卡:讓孩子們愛上編程(全彩)
- Android 游戲開發(fā)大全(第二版)
- MongoDB Administrator’s Guide