最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序?qū)崿F(xiàn)井字棋游戲

 更新時間:2022年05月23日 15:36:53   作者:換日線°  
這篇文章主要為大家詳細介紹了微信小程序?qū)崿F(xiàn)井字棋游戲,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了微信小程序?qū)崿F(xiàn)井字棋游戲的具體代碼,供大家參考,具體內(nèi)容如下

效果圖

.wxml

<view class="title">
? <view wx:if="{{currindex < 9 || defeat}}">
? {{defeat?'勝出方:':'輪到了:'}}<span class="span">{{defeat?(outindex?'○':'x'):(outindex?'x':'○')}}</span>
? </view>
? <view wx:else>平局</view>
</view>
<view class="curr_toe">
? <view wx:for="{{detail}}" wx:key="index" class="curr_item"?
? bindtap="{{item.type > 0 || defeat?'':'tactoe'}}" data-index="{{index}}">
? ? <view wx:if="{{item.type > 0}}">{{item.type == 1?'○':'×'}}</view>
? </view>
</view>
<button wx:if="{{defeat || currindex > 8}}" bindtap="reset">重新開始</button>

.wxss

page{background: #fff;}
.title{width: 100%;display: flex;align-items: center;justify-content: center;margin-top: 20rpx;font-size: 34rpx;}
.span{font-size: 60rpx;}
.curr_toe{width: 510rpx;height: 510rpx;margin: 30rpx calc((100% - 500rpx) / 2);border-top:1px solid #ddd;border-right: 1px solid #ddd;}
.curr_item{border-left: 1px solid #ddd;width: 33.33%;height: 170rpx;display: flex;align-items: center;justify-content: center;color:red;
font-size:170rpx;float: left;border-bottom: 1px solid #ddd;}

.js

Page({
? data: {
? ? lines:[
? ? ? [0, 1, 2],
? ? ? [3, 4, 5],
? ? ? [6, 7, 8],
? ? ? [0, 3, 6],
? ? ? [1, 4, 7],
? ? ? [2, 5, 8],
? ? ? [0, 4, 8],
? ? ? [2, 4, 6],
? ? ]
? },
? onLoad: function (options) {
? ? this.reset()
? },
? reset(e){
? ? this.setData({
? ? ? detail:[
? ? ? ? {type:0},{type:0},{type:0},{type:0},{type:0},{type:0},{type:0},{type:0},{type:0}
? ? ? ],
? ? ? defeat:false,
? ? ? outindex:false,
? ? ? currindex:0
? ? })
? },
? tactoe(e){
? ? var index = e.currentTarget.dataset.index,currindex = this.data.currindex,
? ? detail = this.data.detail,outindex = this.data.outindex;
? ? currindex++
? ? detail[index].type = outindex?2:1
? ? this.setData({
? ? ? detail:detail,
? ? ? currindex:currindex,
? ? ? outindex:!outindex
? ? })
? ? if(currindex > 4){
? ? ? this.validate()
? ? }
? },
? validate(e){
? ? var detail = this.data.detail,lines = this.data.lines;
? ? for(let i = 0;i < lines.length;i++){
? ? ? const [a, b, c] = lines[i];
? ? ? if(detail[a].type && detail[a].type == detail[b].type && detail[a].type == detail[c].type){
? ? ? ? wx.showModal({
? ? ? ? ? title: '提示',
? ? ? ? ? content: (detail[a].type == 1?'○':'×')+'獲得了勝利',
? ? ? ? ? showCancel:false,
? ? ? ? ? confirmText:'我知道了'
? ? ? ? })
? ? ? ? this.setData({
? ? ? ? ? defeat:true
? ? ? ? })
? ? ? ? return false;
? ? ? }
? ? }
? },
})

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

金溪县| 洛川县| 沅陵县| 长葛市| 壶关县| 佳木斯市| 山阴县| 南开区| 黄浦区| 垣曲县| 霍山县| 洪泽县| 铜山县| 牡丹江市| 黑龙江省| 兰考县| 兖州市| 四川省| 许昌市| 临清市| 海宁市| 库尔勒市| 衡水市| 葫芦岛市| 灵石县| 昭苏县| 香格里拉县| 山东省| 通榆县| 江口县| 滨州市| 九龙城区| 罗江县| 安新县| 甘谷县| 丰都县| 亳州市| 荥经县| 泽州县| 六安市| 乐业县|