小技巧四则: 点击空白处隐藏input,下拉刷新,全局变量
发布:2018-01-30 12:07浏览:
次来源:网络 作者:cola
wxml:
-
<scroll-view style="height: {{windowHeight}}px; width: {{windowWidth}}px;" scroll-y="true" bindscrolltoupper="pullDownRefresh" bindscrolltolower="pullUpLoad" bindtap="click_blank">
-
<view wx:if="{{comment}}" class="comment-input"><input type="text" name="content" auto-focus placeholder-style="margin-top:-8rpx;" placeholder="{{comment_placeholder}}" bindchange="comment_input" /><button>发送</button></view>
js:
-
// 评论(点击空白处隐藏input,点击评论出现)
-
click_blank:function(e){
-
var flag = "";
-
var comment_placeholder ="";
-
if(e.target.dataset.comment==1){
-
flag = true;
-
comment_placeholder = e.target.dataset.username;
-
}else{
-
flag = false;
-
comment_placeholder = "";
-
}
-
this.setData({
-
comment:flag,
-
comment_placeholder:"评论"+comment_placeholder+"动态"
-
})
-
},
二:下拉刷新
wxml:
-
<view wx:if="{{items}}">
-
<scroll-view scroll-y="true" bindscrolltoupper="upper" bindscrolltolower="lower" style="height: {{windowHeight}}px">
-
<view wx:for="{{items}}">
-
<view class="item">
-
<view class="item-top">
-
<view class="avatar" wx:if="{{item.avatar}}">
-
<image mode="aspectFill" src="{{'https://uerb.net/'+item.avatar}}"></image>
-
</view>
-
<view class="avatar" wx:else><image mode="aspectFill" src="../img/default_img.png"></image></view>
-
<view class="item-username">
-
<text>{{item.username}}{{item.jobname}}</text>
-
</view>
-
<view class="item-time">{{item.adddate}}</view>
-
</view>
-
</view>
-
</view>
-
<view wx:if="{{hasMore}}">
-
<view wx:if="{{nomore}}" class="tips">
-
<text>没有更多内容了</text>
-
</view>
-
<view wx:else class="tips">
-
<image src="../img/loading.gif" mode="aspectFill"/>
-
<text>玩了命的加载中...</text>
-
</view>
-
</view>
-
</scroll-view>
-
<loading hidden="{{loading}}">加载中...</loading>
js:
-
Page({
-
data: {
-
windowHeight:"",//屏幕高
-
page:1,
-
totalPage:"",//总页数
-
nomore:false,//加载完所有信息显示
-
<
|
免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。