微信小程序笔记

微信小程序标签

view button  block image text

小程序常识:

宽度:750rpx

高度:wx.getSystemInfoSync()  【API里提供同步方法wx.getSystemInfoSync() 异步方法wx.getSystemInfo() 获得高宽信息】 

微信小程序循环

1.控制右侧滚动条,滚动距离

 moreComment:function(){
    var obj = {};
    obj.curHdIndex = 1;
    obj.curBdIndex = 1;
    this.setData({
      tabArr: obj,
    })

    // 控制滚动
    if(wx.pageScrollTo) {
      wx.pageScrollTo({
        scrollTop: 800
      })
    }
  },

2.滚动悬浮菜单

js文件

// 监听滚动条坐标
  onPageScroll: function (e) {
    //console.log(e)
    var that = this
    var scrollTop = e.scrollTop
    var commentFixed = scrollTop > 801 ? true : false
    that.setData({
      commentFixed: commentFixed
    })
  },

wxml文件

<view class="box goods-nav {{commentFixed==true?'goods-nav-fixed':''}}"></view>

wxss文件

.goods-nav-fixed{position: fixed; top: 0;  100%;}

3.小程序订单来源

// 页面初始化数据
  onLoad: function (o) {
    // 渠道来源
    var cps = '';
    if(o.cps)cps = o.cps;
    app.put('cps', cps);
    // 渠道来源 End
   
  },

query 参数,主要用于分享出去,用户点击链接后进入小程序。所得到的参数

原文地址:https://www.cnblogs.com/wesky/p/7590748.html