小程序
小游戏
企业微信
微信支付
扫描小程序码分享
我把scroll-view做成了缩略图,并且点击后放大并切换轮播图
我想在页面加载时直接开始其中一个的动画,我要怎么触发呢?
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
onLoad 执行动画
--↓↓👍如果觉得有帮助的话请点个【赞】吧(唏嘘也有小尾巴了,可惜是假的)
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
你把点击事件的那个function,放到onLoad里,不就行了
changepage: function (event) {
//元素下标
var currentIndex = event.currentTarget.dataset.index;
//清除动画
this.closeAnim();
//开启动画
this.startAnim(currentIndex);
},
startAnim(currentIndex) {
this.animation.width(150).height(160).step();
console.log(this.animation.width)
this.setData({
animation: this.animation.export(),
currentAnimIndex: currentIndex
})
closeAnim() {
this.animation.width(75).height(80).step();
animation: this.animation.export()
}
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
onLoad 执行动画
--↓↓👍如果觉得有帮助的话请点个【赞】吧(唏嘘也有小尾巴了,可惜是假的)
--↓↓👍如果觉得有帮助的话请点个【赞】吧(唏嘘也有小尾巴了,可惜是假的)
--↓↓👍如果觉得有帮助的话请点个【赞】吧(唏嘘也有小尾巴了,可惜是假的)
你把点击事件的那个function,放到onLoad里,不就行了
changepage: function (event) {
//元素下标
var currentIndex = event.currentTarget.dataset.index;
//清除动画
this.closeAnim();
//开启动画
this.startAnim(currentIndex);
},
startAnim(currentIndex) {
this.animation.width(150).height(160).step();
console.log(this.animation.width)
this.setData({
animation: this.animation.export(),
currentAnimIndex: currentIndex
})
},
closeAnim() {
this.animation.width(75).height(80).step();
this.setData({
animation: this.animation.export()
})
}