Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
chenky opened this issue Sep 14, 2024 · 2 comments
Open

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

chenky opened this issue Sep 14, 2024 · 2 comments
Labels

Comments

@chenky
Copy link

chenky commented Sep 14, 2024

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

@Otto-J
Copy link
Member

Otto-J commented Oct 17, 2024

经过我测试最新的 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 Otto-J added mp-weixin 微信小程序 无后续反馈将自动关闭 autoclouse and removed mp mini program uni api 咨询 labels Oct 17, 2024
@Otto-J
Copy link
Member

Otto-J commented Oct 17, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants