开发微信小程序遇到的坑

122 阅读1分钟

1 分享小程序到小程序

pages.json上面要配置

{
    "path": "pages/index/index",
    "style": {
        "navigationBarTitleText": "",
        "navigationStyle": "custom",
        "singlePage" : {
             "navigationBarFit": "squeezed" // 配置这个,否则会被挡住
        }
    }
},

2. 使用后退时 getCurrentPages 安卓与ios的结不一样, ios会关闭页面,andorid不会

    uni.navigateBack({
        success() {
            const pages = getCurrentPages();
            pages.forEach(item => { //直接forEach, 合要求的页面调用刷新
                if (item.__route__ === 'pages/dailyInspection/inspectionDetail') {
                    item.$vm.updateData({
                        inspectionItem: inspectionRow.value,
                        index: gindex.value,
                        allItem: allItem.value
                    })
                }
            })
        }
    })

3.分享 vue3.0全局添加onShareAppMessage

const share = {
    onShareAppMessage: function() {
      return {
        path: 'pages/index/index',
        title: '安得智造供应链'
      }
    },
    onShow() {
      uni.showShareMenu({
        withShareTicket: true,//要求小程序返回分享目标信息
        menus: ['shareAppMessage', 'shareTimeline']
      })
    }
}
 const app = createSSRApp(App);
  app.mixin(share);