开源小程序

  • 首页
  • 编程
  • 工具
    • 在线音乐

uniapp 分享不生效

  • nepiedg
  • 2023-02-11
  • 0

uniapp 分享提示share方法不存在

错误代码

<view class="text-lg flex flex-col mt-4">
      <view class="flex mt-4">
          <u-button type="primary" @click="wxLogin"> 免费注册使用 </u-button>
      </view>
      <view class="mt-4 pb-10">
          <u-button type="primary" @click="shareUrl"> 分享给好友 </u-button>
      </view>
  </view>
const shareUrl = () => {
    // #ifdef MP-WEIXIN
    uni.share({
        provider: 'weixin',
        type: 0,
        href: '<https://www.asds.com>',
        title: '能写作',
        summary: '一文案',
        imageUrl: '<https://www.doasdsa.com/static/images/icon/logo.png>'
    })
    // #endif
}

正确需要添加 open-type="share”


<view class="text-lg flex flex-col mt-4">
    <view class="flex mt-4">
        <u-button type="primary" @click="wxLogin"> 免费注册使用 </u-button>
    </view>
    <view class="mt-4 pb-10">
        <u-button type="primary" open-type="share" @click="shareUrl"> 分享给好友 </u-button>
    </view>
</view>
© 2023 开源小程序
Theme by Wing
备案编号:鲁ICP备18024886号
  • {{ item.name }}
  • {{ item.name }}