微信小程序

2017-10-16  本文已影响0人  Sharise_Mo佩珊

组件使用问题

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

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

<view wx:for="{{labelList}}" class="label-item {{item.isActive?'label-active' : '' }}">{{item.name}}</view>

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

image.png

4、页面传参

 <navigator url="/pages/order/order-detail/index?id={{item.id}}" class="flex title-box"></navigator>

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

image.png

工具问题

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

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

image.png
image.png

API调用问题

wx.checkSession({
  success: function(){
    //session 未过期,并且在本生命周期一直有效
  },
  fail: function(){
    //登录态过期
    wx.login() //重新登录
    ....
  }
})

引用外部资源:js和wxss

js

// format.js
const formatTime = ()=>{}
module.exports = {
  formatTime: formatTime
}

// index.js 引入
const format = require('../../utils/format)
//使用
format.formatTime()

wxss

// index.wxss
@import '../../common.wxss'
上一篇 下一篇

猜你喜欢

热点阅读