关于微信小程序:微信小程序-记录

一. 装置 npm。

二. 自定义 底部 tab bar。

小程序 自定义底部 tab bar

三. 短视频模式 video-swiper。

微信小程序 短视频模式 video-swiper

四. 全局分享。

app.js

App({
  onLaunch() {
    this.onShare();
  },
  // 自定义全局分享
  onShare() {
    wx.onAppRoute((res) => {
      //获取以后页面的对象
      let pages = getCurrentPages();
      let view = pages[pages.length - 1];

      if (view) {
        wx.showShareMenu({
          withShareTicket: true,
          menus: ['shareAppMessage', 'shareTimeline']
        });

        let shareOption = JSON.parse(JSON.stringify(view.options));
        let shareOptionStr = '';
        for (let i in shareOption) {
          shareOptionStr += `&${i}=${shareOption[i]}`
        };

        if (!view.onShareAppMessage &&
          Object.prototype.toString.call(view.onShareAppMessage) !== '[object Function]') {
          view.onShareAppMessage = function () {
            return {
              title: 'xxx',
              path: view.route + (!shareOptionStr ? '' : '?' + shareOptionStr)
            }
          };
        };

        if (!view.onShareTimeline &&
          Object.prototype.toString.call(view.onShareTimeline) !== '[object Function]') {
          view.onShareTimeline = function () {
            return {
              title: 'xxx',
              path: view.route + (!shareOptionStr ? '' : '?' + shareOptionStr)
            }
          };
        };
      };
    });
  },
})

Good luck。

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理