12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- // compontents/target/target.js
- Component({
- /**
- * 组件的属性列表
- * 学习目标 这个组件没啥说的
- */
- properties: {
- wxObjectives: {
- type: Array,
- value: []
- }
- },
- /**
- * 组件的初始数据
- */
- data: {
- flag: false,
- animationData: {},
- downUp: '展开',
- src: '../../pages/image/toDown.png'
- },
- /**
- * 组件的方法列表
- */
- methods: {
- onTap (e) {
- let flage = e.target.dataset.flag;
- if(flage){
- this.util(flage, '120rpx');
- this.setData({
- 'flag': false,
- 'downUp': '展开',
- 'src': '../../pages/image/toDown.png'
- })
- } else {
- this.util(flage, '100%');
- this.setData({
- 'flag': true,
- 'downUp': '收起',
- 'src': '../../pages/image/toUp.png'
- })
- }
- },
- /* 创建动画并执行 */
- util (flag, height) {
- // 创建动画实例
- var animation = wx.createAnimation({
- duration: 200, //动画时长
- timingFunction: "linear", //线性
- delay: 0 //0则不延迟
- });
-
- this.animation = animation;
- animation.height(height).step();
- this.setData({
- animationData: animation.export()
- })
- }
- }
- })
|