WeChat Mini Program Review/1

  1. Click event bindtap to pass parameters through data-
  2. Jump to wx.nav...The parameters are passed through url, and then obtained through options
  3. Loop wx:for={ {}} gives index item by default
  4. The Input tag realizes the two-way binding function, you have to add a bindinput="function name", and get the value you input each time through the detail.value in e.
  5. Regular reg.test() to match is true or false
  6. Save it in the global var app = getApp(), write it in the head, because it can be used, the following is obtained through app.globalData. or something
  7. Onload is executed only once. The status displayed here can be updated during onshow.
  8. Insert picture description here
  9. One way to store data is to store the global, and the other is to store it locally, because the first time you open the process, the global is there, and the next time you come in, the global will be gone, so you need to save it twice, and save it locally, wx .set or get storageSync, the value is in the form of key-value pairs, for example:'phone', aaa
  10. Obtaining user information is best combined with open-type="userInfo", bindgetuserinfo="xxx", which means that the user information is obtained and then xxx is called
  11. wx.removeStorageSync("key value") As the name implies, delete
  12. Changing the value of globalData of one page will not change the value of other pages. It needs to be updated manually. It feels like updating the data from onShow, because it is not like vue, which needs to be updated manually, setData.
  13. The child parent page passes the value, the father child passes the url, the child parent passes the value, the code is for example:
    var pages = getCurrentpages()
    var prevPage = pages[pages.length-2] This means that you can return to the previous page
    prevPage.setData({ }) To update the value of the previous page, this prevPage represents the this of the previous page, and it feels like updating the value of another page on another page. You can also set a function in the parent page, pass the prevPage. parent page method in the child page (parameters need to be passed), and then it's ok.
  14. Modify local variables in data:
    listData:[{id:1, name:"zz"}]
    Like this, I want to modify the name value:
    this.setData({ ["listData[0].name"]: "aa" })
    Index can be used for normal string splicing. This teacher speaks python, and I feel that it can be spliced ​​with es6, and the problem of this in the function, I feel that it is so troublesome to save without that, the arrow function is over, and the performance is not good. .

I have summed up so much in the last few days, huh ╯^╰

Guess you like

Origin blog.csdn.net/weixin_46013619/article/details/105417802