1、wx.request 只能訪問 https
解決: 新建項目 不填appid 即可訪問 localhost
2、頁面中多重三元表達式 解析有問題
解決:
<!--{{index}} {{(index==0)?"A": (index==1)?"B": (index==2)?"C":"D"}}--> <block wx:if="{{index==0}}">A</block> <block wx:elif="{{index==1}}">B</block> <block wx:elif="{{index==2}}">C</block> <block wx:else="{{index==3}}">D</block>
3、Page({data:{}}) 頁面里 data 的值 可以通過 that.setData 設置 但是 怎么直接取出來 在 js 里面用呢
解決: 在page 之外定義全局變量 和page 內的data中的變量 一一對應 每次 賦初始值或者更改 先給全局變量賦值或者 做更改 然后把 更新后的全局變量賦值給 page 內 data 中 對應的變量 代碼如下
var app=getApp(); var globalTestPaperID="", globalTestPaperTitle="", globalTestPaperNum="", globalQuestionList=[], globalQuestionIndex=0, globalQuestion={}, // globalAnswerList={}, globalUserSelectAnswer={}, golbalUserSelectAnswerContent="" Page({ data:{ testPaperID:"", testPaperTitle:"", testPaperNum:"", questionListSize:0, questionIndex:0, question:{}, answerList:{}, userSelectAnswerContent:"" }, onReady:function(){}, onLoad:function(query) { var that=this; console.log("testPaperTitle-->"+query.testPaperTitle); console.log("testPaperID-->"+query.testPaperID); console.log("testPaperOrderNum-->"+query.testPaperOrderNum); globalTestPaperID=query.testPaperID globalTestPaperTitle=query.testPaperTitle globalTestPaperNum=query.testPaperOrderNum that.setData({ // testPaperID:query.testPaperID, // testPaperTitle:query.testPaperTitle, // testPaperNum:query.testPaperOrderNum testPaperID:globalTestPaperID, testPaperTitle:globalTestPaperTitle, testPaperNum:globalTestPaperNum }),
4、關於布局 最好都用 flex 去布局
布局時的 尺寸 我用的是 px 和ps 里的設計圖有差距 如果ps 里字號是 30px 小程序對應的大概是 15px; 其他單位 如 rpx rem 等 暫未做測試
5、form表單提交(發送模板消息),formId返回 the formId is a mock one;代碼中綁定了appid
解決。在開發工具中無法獲取這個formId,只能在手機上獲取。(群里聊天搜集來的 待驗證)
6、圖片上傳