- 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.
推薦閱讀
- 極簡算法史:從數學到機器的故事
- C# 7 and .NET Core Cookbook
- VMware View Security Essentials
- Java系統分析與架構設計
- 軟件架構設計:大型網站技術架構與業務架構融合之道
- Docker進階與實戰
- OpenStack Cloud Computing Cookbook(Fourth Edition)
- 區塊鏈:以太坊DApp開發實戰
- 數據結構(C語言)
- 重學Java設計模式
- Mathematica Data Analysis
- 從Java到Web程序設計教程
- R語言與網絡輿情處理
- Learning Unreal Engine Android Game Development
- C# Multithreaded and Parallel Programming