Home  >  Article  >  Web Front-end  >  WeChat applet todolist

WeChat applet todolist

高洛峰
高洛峰Original
2016-11-21 16:38:051974browse

weixinApp WeChat applet toDoList

List page

Simple list page and data addition, there are some problems at this time

setData has some problems when clearing some user interaction pages.

inputA is an input box. When I submit data, I need to clear the form data. SetData cannot clear it well.

Add data

Use wx.setStorageSync(KEY,DATA).

try {
    wx.setStorageSync('key', 'value')
} catch (e) {
}

Delete data

Use wx.removeStorageSync(KEY)

try {
  wx.removeStorageSync('key')
} catch (e) {
  // Do something when catch error
}

Details page

The routing mechanism is used at this time

<navigator url="/test/logs" >
    查看
</navigator>

Modular testing

Using some ES syntax

WeChat wx.request

wx.request initiates an https request. A WeChat applet can only have 5 network request connections at the same time.

When testing wx.request.

wx.request post passes parameters, but the developer server cannot get the parameters

// 在php内嵌入此句也不适合。
header(&#39;Access-Control-Allow-Origin:*&#39;);
// 可能要在nginx 服务器上配置一些参数,可以让微信小程序调用

Basically, there is no problem with getting. (There is no problem with various url parameters)

Other APIs have not been tested and are not used much. If necessary, test them again.

var count = 0
var maxRequest = 100
var getRequest = function(){

    wx.request({
        // 此域名必需要配置
        url: &#39;https://test.com/t/wxRes&#39;, //仅为示例,并非真实的接口地址
        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次

I found a problem during testing. Posting data has been unsuccessful. Draw conclusions after reviewing the documentation. Need to add a piece of code



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn