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

The castles

This one is actually pretty simple since it consists of only two images and a castle-banners component that will take care of the health and food display:

  1. In the world.js file, create a new castle component with two images that accepts a players and an index prop:
      Vue.component('castle', {
template: `<p class="castle" :class="'player-' + index">
<img class="building" :src="'svg/castle' + index + '.svg'" />
<img class="ground" :src="'svg/ground' + index + '.svg'" />
<!-- Later, we will add a castle-banners component here -->
</p>`,
props: ['player', 'index'],
})

For this component, there is a castle and a ground image for each player; that means four images in total. For example, for the player at index 0, there are castle0.svg and the ground0.svg images.

  1. In the main template, just below the top-bar component, create a new p element with the world CSS class, loop over the players to display the two castles, and add another p element with the land class:
      <p class="world">
<castle v-for="(player, index) in players" :player="player"
:index="index" />
<p class="land" />
</p>

In the browser, you should see one castle for each player, as follows:

主站蜘蛛池模板: 扶绥县| 广安市| 富顺县| 井冈山市| 西峡县| 太白县| 团风县| 监利县| 罗城| 洪江市| 苍山县| 芮城县| 宾阳县| 广灵县| 德令哈市| 海宁市| 云龙县| 车致| 灯塔市| 民勤县| 贵南县| 汶川县| 肇州县| 纳雍县| 富蕴县| 永靖县| 广灵县| 翁牛特旗| 普陀区| 从化市| 华阴市| 申扎县| 永城市| 济南市| 霍州市| 新乐市| 图木舒克市| 伊金霍洛旗| 定襄县| 甘谷县| 海南省|