uni-app icon indicating copy to clipboard operation
uni-app copied to clipboard

vue3 setup scirpt语法使用onShareAppMessage不生效 #3084

Open chenky opened this issue 1 year ago • 2 comments

这个bug还是存在根本不生效,如何定义全局分享,同时详情页可以自定义分享,要同时满足这两项,请告诉我们该如何写代码,使用的是3.2.45版本 错误参考: https://github.com/dcloudio/uni-app/issues/3084

chenky avatar Sep 14 '24 09:09 chenky

经过我测试最新的 HBuilderX alpha 运行 vue3 到微信小程序,下面代码可以生效,你根据下面的 demo 再提问吧

<template>
  <view>
    <view> setup 测试 vu3 微信下程序 setup onShareAppMessage</view>
    <button open-type="share">主动分享</button>
  </view>
</template>
<script setup>

import {onShareAppMessage} from '@dcloudio/uni-app'
  onShareAppMessage ((res)=>{
    if (res.from === 'button') {// 来自页面内分享按钮
      console.log(res.target)
    }
    console.log(111,'on share app message',res)
    return {
      title: '跳转 about 页面',
      path: '/pages/about/index?id=123'
    }
  })

  </script>

<style></style>

Otto-J avatar Oct 17 '24 07:10 Otto-J

我测试 app.mixin 或者单独导入都是 ok 的,对应你说的全局默认分享,不过都组合式 api 了,引用透明对工程化很重要,还是建议通过引入的方式来做

Otto-J avatar Oct 17 '24 08:10 Otto-J

image 已经使用了最新的ide,vue3 setup下,onShareAppMessage不生效。

quanmingmin avatar Dec 10 '24 08:12 quanmingmin