代码如下
wxml:
<
view
class=
'{{san?"v1":"v2"}}'
bindtap=
"selectList"></
view
>
css:
.v1 {
width:
100
rpx;
height:
100
rpx;
background:
red;
border-radius:
50
rpx;
}
.v2 {
width:
100
rpx;
height:
100
rpx;
background:
gray;
border-radius:
50
rpx;
}
js:
Page({
data: {
san:
true,
i:
1,
//变量
},
// 声明一个变量,并判断这个变量
selectList:
function () {
var that =
this;
console.log(that.data.i,
"i")
if (that.data.i ==
1) {
that.data.i =
2,
that.setData({
san:
false,
})
}
else {
that.data.i =
1,
that.setData({
san:
true,
})
}
console.log(that.data.i,
"i2222")
},
})