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

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:

主站蜘蛛池模板: 阿拉善左旗| 孟津县| 台南县| 平阳县| 吉木乃县| 靖西县| 江都市| 陵水| 武鸣县| 当涂县| 瑞丽市| 金门县| 沧源| 大庆市| 昆明市| 资讯 | 郑州市| 行唐县| 江川县| 刚察县| 都安| 霞浦县| 仁寿县| 乌拉特中旗| 三原县| 静宁县| 图木舒克市| 三河市| 镶黄旗| 陈巴尔虎旗| 宜宾县| 栾川县| 普兰店市| 临安市| 大石桥市| 康平县| 尖扎县| 长沙县| 金坛市| 石楼县| 榕江县|