<!--pages/game/game.wxml-->
<view class="container">
<view>玩家得分:{{score}}</view>
<canvas canvas-id="gameCanvas" />
<view class="btnBox">
<button type="primary" size="mini" bind:tap="changeDirection" data-direct = "{{2}}" data-img = "up">↑</button>
<view>
<button type="primary" size="mini" bind:tap="changeDirection" data-direct = "{{1}}" data-img = "left">←</button>
<button type="primary" size="mini" bind:tap="changeDirection" data-direct = "{{-2}}" data-img = "down">↓</button>
<button type="primary" size="mini" bind:tap="changeDirection" data-direct = "{{-1}}" data-img="right">→</button>
</view>
<button type="primary" size="mini" bind:tap="initGame">重新开始</button>
</view>
</view>
标签:得分,score,wxml,玩家,game,贪吃蛇 From: https://blog.51cto.com/u_16349720/9088169