网友真实露脸自拍10p,成人国产精品秘?久久久按摩,国产精品久久久久久无码不卡,成人免费区一区二区三区

小程序模板網

微信小程序開發問答《六十》錯誤狀態碼(例如:401)的獲取& 日期選擇器的起始

發布時間:2018-04-23 11:13 所屬欄目:小程序開發教程
1、微信小程序錯誤狀態碼(例如:401)的獲取

當小程序請求后端接口時,可能返回狀態碼:

200(請求成功)
401(請求需要用戶驗證)
404(請求失敗)

...

在wx.request()的fail: function(data) 中 獲取不到
4**,5** 的狀態碼需要在success 中獲取 :


success: function(data) {
   console.log(data.statusCode)
}

fail回調一般源于在url格式、參數類型檢查、網絡連接、域名解析、response編碼問題等

 

2、日期選擇器的起始時間極限值

<picker class="information-item-text information-item-right information-item-picker" mode="date" value="{{birthday}}" start="1971-01-01" end="2017-12-31" bindchange="bindDateChange" disabled="{{!editable}}">
      <view class="information-item-picker-text">{{birthdayStr}}</view>

    </picker>

小程序的日期選擇器,關鍵問題在于start(起始時間),該值有個極限值。

模擬器上沒有極限值,但是在手機上顯示的話,如果早于該極限值的話,則顯示的是上一次設置有效的起始值,如果沒有設置的話,則是end的前3年作為起始值。

不知道是自己的操作有問題還是設置有問題,偏偏讓我遇到了這個問題。本來在模擬器上一切正常,結果到了手機上起始時間錯了,然后百度搜索,結果搜到的一堆都是類似小程序組件picker的教程,毫無用處,難道只有我遇到嗎,我真不信,或許這是小程序手機適配的BUG嗎。為了用戶體驗,只能嘗試去找出這個極限值,目前找到的是1971年。

測試手機:紅米3

 

3、通過微信小程序平臺提供的接口 訪問日活數據 date format錯誤?

https://api.weixin.qq.com/dat...
POST 內容示例:

{
"begin_date" : "20170313",
"end_date" : "20170313"
}


            CloseableHttpClient httpClient = createSSLClientDefault();
            HttpPost httpPost = new HttpPost();
            httpPost.setURI(new URI(url));
            httpPost.setEntity(new UrlEncodedFormEntity(nvps));

            CloseableHttpResponse response = httpClient.execute(httpPost);
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                String result = EntityUtils.toString(entity, "UTF-8");
                System.out.println("Response content: " + result);
                return result;
            }

Response content: {"errcode":61500,"errmsg":"date format error hint: [Dy5YZa0787e541]"}

答:你看,


{
"begin_date" : "20170313",
"end_date" : "20170313"
}

這是一個json的傳參格式,而你用的卻是urlencoded方式

httpPost.setEntity(new StringEntity(params.toString(), "UTF-8"));

 

4、bindtap事件與bindtouchstart和bindtouchend事件沖突


<view class="container" catchtouchstart="handleTouchStart" catchtouchend="handleTouchEnd">
    <scroll-view scroll-y class="wrapper">
        <view class="list-item" wx:for="{{list}}" wx:key="{{item.id}}" data-id="{{item.id}}" catchtap="handletap">
            <image class="image" src="{{item.img}}"></image>
            <view class="right">
                <text class="title">{{item.title}}</text>
                <text class="intro">{{item.intro}}</text>
                <text class="time">{{item.time.date}}</text>
            </view>
        </view>
    </scroll-view>
</view>

代碼如上,當點擊.list-item時并沒有觸發bindtap事件,而是觸發了catchtouchstart,catchtouchend

把catchtouchstart,catchtouchend事件移除后,能正常捕捉bindtap

請問有什么好的方法解決,catchtouchstart,catchtouchend事件不能移除,另有他用。

答:

tap,touchstart,touchend的事件觸發順序為start→end→tap
所以問題在于catchtouchstart,catchtouchend后事件被阻止了,tap捕獲不到。
改為bindtouchstart,bindtouchend后問題得以解決。

 


易優小程序(企業版)+靈活api+前后代碼開源 碼云倉庫:starfork
本文地址:http://www.xiuhaier.com/wxmini/doc/course/23902.html 復制鏈接 如需定制請聯系易優客服咨詢:800182392 點擊咨詢
QQ在線咨詢
AI智能客服 ×