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

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.

主站蜘蛛池模板: 旅游| 平罗县| 定南县| 罗城| 大丰市| 平江县| 湘潭市| 桐梓县| 玛沁县| 临泽县| 义马市| 普兰店市| 开化县| 云龙县| 枝江市| 铁岭县| 合江县| 绥芬河市| 轮台县| 赤壁市| 土默特左旗| 建始县| 久治县| 商水县| 阿合奇县| 耒阳市| 荣昌县| 沁水县| 平度市| 江油市| 托克逊县| 靖安县| 鄱阳县| 通山县| 沂水县| 辽阳县| 上蔡县| 桦南县| 建始县| 南昌县| 漳州市|