| 主機參考:VPS測評參考推薦/專注分享VPS服務器優惠信息!若您是商家可以在本站進行投稿,查看詳情!此外我們還提供軟文收錄、PayPal代付、廣告贊助等服務,查看詳情! |
| 我們發布的部分優惠活動文章可能存在時效性,購買時建議在本站搜索商家名稱可查看相關文章充分了解該商家!若非中文頁面可使用Edge瀏覽器同步翻譯!PayPal代付/收錄合作 |
本文主要介紹微信小程序開發中遇到問題的相關信息,有需要的朋友可以參考。
微信小程序開發中遇到的問題總結
第一次正式開發小程序,我們從以下幾個方面來談談小程序的開發過程和經驗,主要是關于本項目中使用的功能。
數據請求
這個小程序沒有太多額外的功能,所以數據和數據處理是這次的主要工作。小程序為用戶提供API,供用戶從自己的服務器請求數據。值得一提的是,在開發小程序之前,需要在微信公眾平臺申請appID并綁定域名。域名必須是https協議,然后在小程序開發工具的配置信息中填寫信息。請求的地址需要在前面綁定的域名下。Wx.request在這個項目中用于從服務器獲取數據。
wx . request({ URL:that . data . coupon data . request URL,data:that . data . coupon data . query data,header:{ & amp;#39;內容-類型&。#39;:& amp#39;應用/JSON & amp;#39;},success:function(RES){ var list = RES . data . goods list;console . log(RES . data);for(列表中的變量I){ list【I】。quanusenum = parse int(list【I】)。quanTotalNum)-parse int(list【I】。quanRemainNum);列出【I】。isImgRendered = false}列表【0】。isImgRendered = list【1】。isImgRendered = list【2】。isImgRendered = list【3】。isImgRendered = truethat . setdata({ & quot;coupon data . total page & quot;:RES . data . total page });that . setdata({ & quot;couponData.list":that . data . coupon data . list . concat(list)});that . setdata({ & quot;couponData.loadmore & quot:!that . data . coupon data . load more });that . setdata({ & quot;coupondata . query data . pagenum & quot;:parse int(that . data . coupon data . query data . pagenum)+1 });if(that . data . coupon data . query data . pagenum & gt;that . data . coupon data . total page){ that . setdata({ & quot;couponData.isAction & quot:false });} if(that . data . coupon data . list . length & lt;1){ that . setdata({ & quot;coupon data . no data & quot;:true });} if(f){ f();} } });數據緩存
這里使用數據緩存是因為它需要搜索功能,這涉及到頁面之間的數據傳輸。放在地址里也是一種方法。您還可以借用localStorage,并使用wx.setStorage將數據存儲在localStorage中。頁面跳轉后,您可以從localStorage中讀取它。讀取數據時,可以同步和異步讀取。
剪切板的應用
借用小程序的API可以輕松地將任何信息復制到剪貼板,然后可以粘貼它。
wx . setclipboarddata({ data:& amp;#39;【& amp#39;+that . data . coupon data . list【e . current target . id】。goods title+& amp;#39;】復制這條消息,打開【手機淘寶】&;#39;+that . data . coupon data . list【e . current target . id】。twoInOneKouling,success:function(RES){ that . setdata({ & quot;coupon data . copy tip & quot;:true,& quotcouponData。寇靈& quot:that . data . coupon data . list【e . current target . id】。twoinekouling })} });模板
在這個項目中,頁面基本相似,但有細微的差異,因此使用一個模板來創建新的template/template.wxml,并且必須設置name屬性。
& lt模板名稱= & amp#39;navsearch & amp#39;& gt& lt查看class = & amp#39;nav -搜索與應用。#39;& gt& lt查看class = & amp#39;na v-search container space -between & amp;#39;& gt& lt查看class = & amp#39;nav -搜索搜索& amp#39;wx:if = & amp;#39;{{isSearch}}。#39;& gt& lt/view & gt;& lt輸入class = & amp#39;nav -搜索輸入& amp#39;占位符= & amp#39;請輸入關鍵字查找優惠券&;#39;name = & amp#39;queryStr & amp#39;value = & quot{ { queryStr } } & quotbindfocus = & amp#39;toggleSearch & amp#39;bindconfirm = & amp#39;doQuery & amp#39;bindinput="同步查詢/& gt;& lt查看class = & amp#39;nav -搜索刪除& amp#39;wx:if = & amp;#39;{{!isSearch } } & amp#39;bindtap = & amp#39;刪除所有內容。#39;& gt& lt/view & gt;& lt查看class = & amp#39;nav -搜索中心。#39;wx:if = & amp;#39;{{!isSearch } } & amp#39;bindtap = & amp#39;doQuery & amp#39;& gt搜索;& lt導入src = & quot/template/template.wxml"/& gt;& lt模板是= & amp#39;navsearch & amp#39;data = & quot{{...couponData } } & quot& gt& lt/template & gt;模塊化
對于公共js,您可以將其編寫在一個特殊的js文件中,然后使用module.exports來公開接口。使用require引入通用js文件。
var common = require(& amp;#39;../../common/common . js & amp;#39;);...common . f();//調用redirectTo & navigateTo。
redirect重定向到頁面,navigateTo打開新頁面。值得注意的是,使用navigateTo打開過多頁面會導致小程序卡頓。
分享
page({ onShareAppMessage:function(){ return { title:& amp;#39;你的頭銜!& amp#39;路徑:& amp#39;/xxxx/xxxx/xxxx & amp;#39;,//分享成功后返回本頁面:function(RES){ f();//回調成功;},fail:function(RES){ f();//回調失敗;}}}})提高列表滑動的流暢性。
簡而言之,頁面滾動到哪里,列表中的圖片就會顯示到哪里。實現方法如下。
//js文件頁面({ load img:function(e){//計算接下來將加載var index = math . floor((e . detail . scroll top -8)/259.5)的哪些片段;var temp = this . data . coupon data . list;//完整列表var min = math . max(index * 2,0),max = math . min(index * 小編8,temp . length);for(var I = min;我& ltmaxi++){ if(temp【I】& amp;& amp!溫度【I】。isImgRendered){ temp【I】。isImgRendered = true//列表中的每一項都有一個標記是否加載圖片的屬性。默認值為false,隨著頁面的滾動一個接一個地變為true。} } this . setdata({ & quot;couponData.list":temp });temp = null},})//wxml文件綁定scroll -視圖上的事件。& ltscroll -view class = & quot;第& quotscroll -y = & quot;true & quotbindscroll = & amp#39;裝載與運輸。#39;& gt& lt/scroll -view & gt;【相關建議】
1.特別推薦:下載php程序員工具箱V0.1版。
2.下載微信微信官方賬號平臺源代碼
3.阿里訂單子系統源代碼下載
這幾篇文章你可能也喜歡:
- 暫無相關推薦文章
本文由主機參考刊發,轉載請注明:微信開發技術經驗總結(微信開發技術經驗總結怎么寫) http://m.k2270.com/114873.html
主機參考

















評論前必須登錄!
注冊