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

小程序模板網(wǎng)

微信小程序開(kāi)發(fā)問(wèn)答《六十》錯(cuò)誤狀態(tài)碼(例如:401)的獲取& 日期選擇器的起始

發(fā)布時(shí)間:2018-04-23 11:13 所屬欄目:小程序開(kāi)發(fā)教程
1、微信小程序錯(cuò)誤狀態(tài)碼(例如:401)的獲取

當(dāng)小程序請(qǐng)求后端接口時(shí),可能返回狀態(tài)碼:

200(請(qǐng)求成功)
401(請(qǐng)求需要用戶(hù)驗(yàn)證)
404(請(qǐng)求失敗)

...

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


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

fail回調(diào)一般源于在url格式、參數(shù)類(lèi)型檢查、網(wǎng)絡(luò)連接、域名解析、response編碼問(wèn)題等

 

2、日期選擇器的起始時(shí)間極限值

<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>

小程序的日期選擇器,關(guān)鍵問(wèn)題在于start(起始時(shí)間),該值有個(gè)極限值。

模擬器上沒(méi)有極限值,但是在手機(jī)上顯示的話(huà),如果早于該極限值的話(huà),則顯示的是上一次設(shè)置有效的起始值,如果沒(méi)有設(shè)置的話(huà),則是end的前3年作為起始值。

不知道是自己的操作有問(wèn)題還是設(shè)置有問(wèn)題,偏偏讓我遇到了這個(gè)問(wèn)題。本來(lái)在模擬器上一切正常,結(jié)果到了手機(jī)上起始時(shí)間錯(cuò)了,然后百度搜索,結(jié)果搜到的一堆都是類(lèi)似小程序組件picker的教程,毫無(wú)用處,難道只有我遇到嗎,我真不信,或許這是小程序手機(jī)適配的BUG嗎。為了用戶(hù)體驗(yàn),只能?chē)L試去找出這個(gè)極限值,目前找到的是1971年。

測(cè)試手機(jī):紅米3

 

3、通過(guò)微信小程序平臺(tái)提供的接口 訪(fǎng)問(wèn)日活數(shù)據(jù) date format錯(cuò)誤?

https://api.weixin.qq.com/dat...
POST 內(nèi)容示例:

{
"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"
}

這是一個(gè)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>

代碼如上,當(dāng)點(diǎn)擊.list-item時(shí)并沒(méi)有觸發(fā)bindtap事件,而是觸發(fā)了catchtouchstart,catchtouchend

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

請(qǐng)問(wèn)有什么好的方法解決,catchtouchstart,catchtouchend事件不能移除,另有他用。

答:

tap,touchstart,touchend的事件觸發(fā)順序?yàn)閟tart→end→tap
所以問(wèn)題在于catchtouchstart,catchtouchend后事件被阻止了,tap捕獲不到。
改為bindtouchstart,bindtouchend后問(wèn)題得以解決。

 


易優(yōu)小程序(企業(yè)版)+靈活api+前后代碼開(kāi)源 碼云倉(cāng)庫(kù):starfork
本文地址:http://www.xiuhaier.com/wxmini/doc/course/23902.html 復(fù)制鏈接 如需定制請(qǐng)聯(lián)系易優(yōu)客服咨詢(xún):800182392 點(diǎn)擊咨詢(xún)
QQ在線(xiàn)咨詢(xún)
AI智能客服 ×