微信小程序一些技巧/错误

1. 返回上一页

 const pages = getCurrentPages();
 const perpage = pages[pages.length - 1];
 perpage.onLoad();

2.Modal中内容如何换行?

  在需要换行的地方加入 '\r\n' (微信开发平台看不到换行,但真机调试可以)

3.this指向问题

function(){
  this.setData({
     xx : xx
  })  
}

会报错,因为function(){}是一个闭包,不能直接用this,这样使用:

var that = this;
function(){
  that.setData({
     xx : xx
  })  
}

 

posted @ 2019-07-05 17:06  decrypt  阅读(241)  评论(0编辑  收藏  举报