<view class="card">
<view wx:for="{
{nowChess}}" wx:key-item="item" wx:for-index="indexs" wx:key="indexs" class="child">
<view wx:for="{
{item}}" wx:key-item="item" wx:key="index" class="children">
<view class="button{
{item}}" bindtap="clickButton" data-indexs="{
{indexs}}" data-index="{
{index}}">
{
{indexs}},{
{index}}
</view>
</view>
</view>
</view>
HTML
for (var i = 0; i < 8; i++) {
for (var j = 0; j < 8; j++) {
this.setData({
["nowChess[" + i + "][" + j + "]"]: 0,
["nowChess[" + 3 + "][" + 3 + "]"]: 2,
["nowChess[" + 4 + "][" + 3 + "]"]: 1,
["nowChess[" + 3 + "][" + 4 + "]"]: 1,
["nowChess[" + 4 + "][" + 4 + "]"]: 2,
})
}
};
初始化二维数组,JS