微信小程序封装的几个常用功能-微信小程序基本功能-微信小程序功能开发
页面中引用varanimaterequire('../../utils/animate.js');show(this,param,time)显示*参数1:this;*参数2param:定义的动画名param参数3time:动画执行时间。默认值400mswxml中调用方法:animation’{{param}}’*使用的元素需要先用hide方法隐藏viewanimation'{{param}}'/viewonReady:function(){letthatthis;animate.hide(that,that.data.param,1);//使用的元素需要先用hide方法隐藏setTimeout(function(){animate.hide(that,that.data.param,500);},500)}hide(this,param,time)隐藏*参数1:this;*参数2param:定义的动画名param参数3time:动画执行时间。默认值400mswxml中调用方法:animation’{{param}}’viewanimation'{{param}}'/viewonReady:function(){letthatthis;animate.hide(that,'pram',1);//使用的元素需要先用hide方法隐藏}isMove(e,direction,callback)触摸方向事件*参数1e:滑动钩子的e对象;*参数2direction:往哪个方向滑动触发(‘left’,‘right’,‘top’,‘bottom’);参数3:回调viewbind:touchmove"isMove"/viewisMove:function(e){letthatthis;animate.isMove(e,'left',(){//如果向左滑动则触发},this)}getHeight(id,callback)获取节点高度*参数1id:节点id;*参数2callback:回调返回目标left,right,top,bottom属性;viewid'ddd'/viewonReady:function(){animate.getHeight('ddd',(res){consonle.log(res)})}getNode(name,arr,callback)获取节点基本属性*参数1name:节点名‘#ddd’/’.aaa’;参数2arr:目前提供的基本属性有:backgroundColor,color,fontSize,height,margin,padding,scrollHeight,scrollLeft,scrollTop,scrollWidth,width;如果想获取的属性这里没有可以填写在arr里*参数3:返回基本属性viewid'ddd'/viewonReady:function(){animate.getNode('#ddd',['border'],(res){consonle.log(res)})}getWxImg(src,callback)网络图片本地化*参数1src:图片网络路径;*参数2callback:回调返回图片基本信息onReady:function(){animate.getWxImg('https://pic2.zhimg.com/50/v2-88fd57c6464e1a313d5c3337aba07458_hd.jpg',(res){consonle.log(res)})}strSm(str,len)分割字符串将字符串分割为字符长度为len的数组*参数1str:需要分割的字符串;参数2len:在长度大于多少时开始分割默认:1onReady:function(){letstr'adadaadaddad'letnewStranimate.strSm(str,5);//[adada,adadd,ad]}fontEllipsis(str,len,end)将多余文字显示为省略号*参数1str:需要处理的字符串;参数2len:在长度大于多少之后为省略号默认为5参数3end:结尾显示内容默认为‘…’onReady:function(){letstr'adadaadaddad'letnewStranimate.fontEllipsis(str,5,'???');//'adada???'}1.
持续更新中。。。。。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

