在这里插入代码片
极其简答就不多说了,直接上代码。
WXML
黑
紫
橙
蓝
绿
JS
data: {
backgroundcolor:‘red’
},
changeColor:function(e){
this.setData({
backgroundcolor: e.currentTarget.dataset.color
})
}
那么下面咱们说一说这个旋转的动画。小程序里呢,有自己的动画api,但是用起来感觉极其麻烦,而且容易产生倒转,对设备的性能消耗也多,动画多了以后就会极其卡顿,所以还是css3的动画比较好。
首先来写这个css3动画
css3旋转动画
<view class='animationSlow'></view>
.animationSlow {
width: 100rpx;
height: 100rpx;
background-color: orange;
animation-name: myfirst; /*动画的名称 */
animation-duration: 2000ms; /*动画从开始到结束的时间*/
animation-timing-function: linear; /*动画执行快慢的参数*/
animation-iteration-count: infinite; /*动画执行多少次的参数*//*以下是兼容ios所需,参数意义与上相同*/
-webkit-animation-name: myfirst;
-webkit-animation-duration: 2000ms;
-webkit-animation-timing-function: linear;