微信小程序

组件使用问题

1、scroll-view滚动到指定位置:用到scroll-view的scroll-into-view属性
使用场景:

  • 按字母顺序滚动
  • 聊天框最新聊天信息在底部

http://blog.csdn.net/zhaoyazhi2129/article/details/53787695
2、动态类名绑定

{{item.name}}

3、分享图片
https://mp.weixin.qq.com/debug/wxadoc/dev/api/share.html#onshareappmessageoptions

微信小程序_第1张图片
image.png

4、页面传参

 

5、生成二维码:http://blog.csdn.net/wtdask/article/details/73776356
6、小程序开卡组件: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1499332673_Unm7V
7、switchTab跳转之后页面不刷新

wx.switchTab({ 
  url: '../index/index', 
  success: function (e) { 
    var page = getCurrentPages().pop(); 
    if (page == undefined || page == null) return; 
    page.onLoad(); 
  } 
}) 

8、动态设置tabbar
https://mp.weixin.qq.com/debug/wxadoc/dev/api/ui-tabbar.html#wxsettabbarstyleobject
API--界面--设置tabbar

微信小程序_第2张图片
image.png

工具问题

1、0.17版本的wx.request()会发不出请求,需要改成0.22版本的就好了

2、善用工具
一个小程序的组件化开发工具wepy
wepy: https://segmentfault.com/a/1190000007580866
github:https://github.com/Tencent/wepy

微信小程序_第3张图片
image.png

微信小程序_第4张图片
image.png

API调用问题

  • wx.getUserInfo(): 能调起授权确认弹窗
  • wx.login(): 调用wx.login()获取登录凭证(code),用code调用服务器后台API换取用户登录态信息,openid,session_key,union_id 【调用login会引起登录态的刷新,之前的sessionKey会失效】
  • wx.request():发起请求
  • wx.checkSession():检查当前用户的登录状态是否有效
wx.checkSession({
  success: function(){
    //session 未过期,并且在本生命周期一直有效
  },
  fail: function(){
    //登录态过期
    wx.login() //重新登录
    ....
  }
})
  • 登录态的维护:


    微信小程序_第5张图片
    image.png

你可能感兴趣的:(微信小程序)