简单的列表页面和数据添加,此时有一些问题javascript
setData在清除一些用户交互的页面的时候有些问题。php
inputA 是一个输入框,当我提交数据的时候,须要清除表单的数据,setData不能清除很好的清除。html
使用wx.setStorageSync(KEY,DATA).java
try { wx.setStorageSync('key', 'value') } catch (e) { }
使用 wx.removeStorageSync(KEY)nginx
try { wx.removeStorageSync('key') } catch (e) { // Do something when catch error }
此时用到路由机制git
<navigator url="/test/logs" > 查看 </navigator>
wx.request发起的是https请求。一个微信小程序,同时只能有5个网络请求链接。github
在测试wx.request的时候.json
wx.request post传参数,开发者服务器取不到参数小程序
// 在php内嵌入此句也不适合。 header('Access-Control-Allow-Origin:*'); // 可能要在nginx 服务器上配置一些参数,能够让微信小程序调用
基本上get是没有问题的。(url各类带参数是没有问题的)segmentfault
其余的API没有测试,用的很少,若是有须要再进行测试。
var count = 0 var maxRequest = 100 var getRequest = function(){ wx.request({ // 此域名必须要配置 url: 'https://test.com/t/wxRes', //仅为示例,并不是真实的接口地址 success: function(res) { count++ if(count < maxRequest){ getRequest() } }, fail: function(res){ console.log(res) } }) } // https请求 for(var i = 0; i< 5;i++){ getRequest() } // 若是直接for10次的话,确定有错误。这里只能for5次
我在测试的时候发现一个问题。post数据的时候一直不成功。通过查看文档得出结论。
须要加一段代码
// log.js // 头部 header: { "Content-Type": "application/x-www-form-urlencoded" }, // 这样的数据是取不到值的。要把参数转化为这个形式才ok, **id=1234444&name=adasdadad** var postData = { id: 1234444, name: 'qidongyou' }; postData = util.json2Form(postData); // util.js function json2Form(json) { var str = []; for(var p in json){ str.push(encodeURIComponent(p) + "=" + encodeURIComponent(json[p])); } return str.join("&"); } module.exports = { json2Form: json2Form }
wx.getImageInfo取远程图片元信息是有问题的。https://36dong.com/assets/ima...,在本地测试是没有问题。