- 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.
推薦閱讀
- The Complete Rust Programming Reference Guide
- 移動(dòng)UI設(shè)計(jì)(微課版)
- Apache Mahout Clustering Designs
- Kotlin從基礎(chǔ)到實(shí)戰(zhàn)
- Windows內(nèi)核編程
- Creating Mobile Apps with jQuery Mobile(Second Edition)
- Scratch趣味編程:陪孩子像搭積木一樣學(xué)編程
- 進(jìn)入IT企業(yè)必讀的324個(gè)Java面試題
- Maven for Eclipse
- Data Manipulation with R(Second Edition)
- Laravel Design Patterns and Best Practices
- H5頁面設(shè)計(jì)與制作(全彩慕課版·第2版)
- 面向物聯(lián)網(wǎng)的Android應(yīng)用開發(fā)與實(shí)踐
- GO語言編程從入門到實(shí)踐
- HTML5 and CSS3:Building Responsive Websites