| 主機參考:VPS測評參考推薦/專注分享VPS服務器優惠信息!若您是商家可以在本站進行投稿,查看詳情!此外我們還提供軟文收錄、PayPal代付、廣告贊助等服務,查看詳情! |
| 我們發布的部分優惠活動文章可能存在時效性,購買時建議在本站搜索商家名稱可查看相關文章充分了解該商家!若非中文頁面可使用Edge瀏覽器同步翻譯!PayPal代付/收錄合作 |

(學習視頻分享:編程視頻)
1.小程序生成一個二維碼。
小程序生成二維碼。小程序其實需要后端調用,然后前端調用后端接口。
在下面的例子中,我們傳遞給后端的場景是一個額外的參數(最大長度為32個字符,只支持數字、大小寫英文和一些特殊字符:!#$&'()*+,/:;=?@-._~,其他字符請編碼為合法字符),在打開的小程序中使用。
讓場景= & amp#39;t = 3 & ampn = & amp#39;+this . input val+& amp;#39;& amp銷售= & amp#39;+this . saleid;request(qcode,{isHyaline:false,qrcodeType:2,scene:scene,width:255,color:{ r:& amp;#39;255 & amp#39;,g:& amp;#39;255 & amp#39;,b:& amp;#39;255 & amp#39;}}) .然后(res = & gt{})})這里的坑在于前端如何獲取用戶如何通過掃描二維碼獲取參數。
onLoad(opts){ var scene = decodeURIComponent(opts . scene);// scene需要decodeURIComponent在生成二維碼時獲取傳入的場景。2.小程序跳轉小程序。
applet調用toMiniProgram,我在這里做了一個簡單的包。
Function tominprogram (appid,path,extradata) {wx。navigator mini program({ appId:appId,//要打開的applet appId path:path,//要打開的頁面路徑env version:&;#39;發展與創新。#39;,//要打開的小程序版本。該參數僅在當前小程序為開發版或體驗版時有效。ExtraData: extraData,//要傳遞給目標applet的數據成功:function(RES){ console . log(&;#39;打開成功&;#39;)},fail:頁面中使用的function (res) {}}。
toMiniProgram(& amp;#39;appid & amp#39;,& amp#39;頁面/客戶/商品-詳細信息?id = & amp#39;+id+& amp;#39;& ampsaleId = & amp#39;+this.saleId,{ });在另一個子視圖中獲取參數
onload(opts){ this . goodsid = opts . id this . saleid = opts . saleid } 3。天花板效果的實現。
天花板效應的原理是將滾動到一定高度的標簽重新排列為固定。
超文本標記語言
& ltview class = & quottab -ctn & quot;& gt& ltview class = & quottabs flex flex -justify { { isTabFixed?& amp#39;固定& amp#39;:& amp#39;& amp#39;} } & quotid = & quot制表符& quot& gt& ltview class = & quotitem pr {{tabIndex===0?& amp#39;on & amp#39;:& amp#39;& amp#39;} } & quot@ tap = & quottoggle tab(0)& quot;& gt產品介紹
。制表符{ padding:0 176 rpx;font -size:30 rpx;身高:90rpxborder -bottom:0.5 px solid # e4e4e 4;}.item{身高:100%;位置:相對;padding -top:20 rpx;顏色:# 999;& amp。on { color:# FD 343 b;font-weight:粗體;}}.固定{位置:固定;top:0;左:0;右:0;z-指數:9;}js
data = { detail top:300,} onLoad(){ this . getelheight(& amp;#39;& amp#39;)tab上方元素的高度}/* *根據ID */getelhighbyID(ID){ Return new promise(function(resolve,reject) {constquery = wx封裝元素高度。CreateSelectorQuery()查詢。選擇(&;#39;# & amp#39;+id)。boundingClientRect()query . select viewport()。scroll offset()query . exec(function(RES){ resolve(RES[0])。height) }) })}//調用getelheight (id) {this。getelhighbyid (id)。然后(RES = > { this . detail top = RES })}/* *監視頁面滾動事件*/on page scroll(e){ if(e . scroll top > = this . detail top & amp;& amp!this . istabfixed){ this . istabfixed = true } else if(e . scroll top & lt;= this.detailTopH & amp& ampthis . istabfixed){ this . istabfixed = false } } 4。封裝時間戳
函數formatTime(時間戳,type = & quot日期& quot){ var date =新日期(時間戳);var year = date . get full year()var month = date . get month()+1 var day = date . get date()var hour = date . get hours()var minute = date . get minutes()var second = date . get seconds()if(type = = & quot;日期& quot){ return[年、月、日]。map(formatNumber)。加入(& amp#39;-& amp;#39;);} else if(type = = & quot;所有& quot){ return[年、月、日]。map(formatNumber)。加入(& amp#39;-& amp;#39;)+& amp;#39;& amp#39;+[時、分、秒]。map(formatNumber)。加入(& amp#39;:& amp#39;)} else if(type = = & quot;時間& quot){ return[小時,分鐘,秒]。map(formatNumber)。加入(& amp#39;:& amp#39;)} else if(type = = & quot;時間& quot){ return[小時,分鐘]。map(formatNumber)。加入(& amp#39;:& amp#39;)} else if(type = = & amp;#39;月份和時間。#39;){ return[月,日]。map(formatNumber)。加入(& amp#39;-& amp;#39;);} }/**niu封裝時間戳格式化輔助,先將年月日轉換成字符串,再判斷是否加0 */functionformatnumber(n){ n = n . tostring()return n[1]?n:& amp;#39;0 & amp#39;+ n} formatTime(1236547891,& amp#39;所有& amp#39;)//2019-11-02 03:11:11 format time(1236547891,& amp#39;時間與空間。#39;)//03:11:22 format time(1236547891,& amp#39;時間& amp#39;)// 03:11formatTime(1236547891,& amp#39;月份和時間。#39;)// 03-03formatTime(1236547891,& amp#39;日期和時間。#39;)// 2019-11-02相關推薦:小程序開發
這幾篇文章你可能也喜歡:
本文由主機參考刊發,轉載請注明:小程序開發的難點是什么(開發小程序難嗎) http://m.k2270.com/118848.html
主機參考

















評論前必須登錄!
注冊