官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 瓦房店市| 靖江市| 长海县| 乐都县| 揭东县| 沾益县| 石家庄市| 抚顺县| 双鸭山市| 工布江达县| 灵丘县| 蛟河市| 保定市| 康乐县| 临湘市| 响水县| 磐安县| 赤城县| 手机| 贵溪市| 浦江县| 西盟| 广元市| 闽侯县| 加查县| 靖州| 阳东县| 鸡泽县| 万源市| 集安市| 信宜市| 蒲江县| 商南县| 旌德县| 诸城市| 观塘区| 宜兴市| 东方市| 永宁县| 吉安市| 马边|