- 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語言程序設計
- ReSharper Essentials
- Linux C/C++服務器開發實踐
- Learning SQLite for iOS
- 高級C/C++編譯技術(典藏版)
- 深入淺出DPDK
- QGIS By Example
- 全棧自動化測試實戰:基于TestNG、HttpClient、Selenium和Appium
- WordPress 4.0 Site Blueprints(Second Edition)
- Learning YARN
- 深入剖析Java虛擬機:源碼剖析與實例詳解(基礎卷)
- 實戰Java高并發程序設計(第2版)
- Application Development with Swift
- C語言從入門到精通
- Hack與HHVM權威指南