欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 时评 > uniapp vue分享功能集成

uniapp vue分享功能集成

2024/10/25 6:24:38 来源:https://blog.csdn.net/qq_36635270/article/details/139679318  浏览:    关键词:uniapp vue分享功能集成
  1. 分享必须通过button设置open-type="share"拉起
<view class="img horizontal center" style="margin-right: 20rpx;"><image class="img" :src="src" @click="onTapClick('xxx')" style="z-index: 1;" /><button v-if="curBarrier > 5" class="share-btn transparent" open-type="share"style="z-index: 2; position: absolute;"></button>
</view>.share-btn {width: 170rpx;height: 56rpx;border: none !important;plain: true;background: transparent;//不加这个属性,隐藏边框抖音可以,快手失效了box-shadow: none;&::after {border: none;}}

基本逻辑就是在某个按钮上面覆盖一个全透明button,这样更方便实现UI设计和交互,z-index则是控制view层级的,越大的再上面,然后position:absolute 设置不受其他view影响,重叠view时也用这个设置

再然后写一个全局通用的分享回调的js方法:

export default {async onShareAppMessage(options) {//options.from 有menu button两个值//options.channel 分享为空‘’, 拍抖音为‘video’console.log(TAG, "onShareAppMessage options:", options)let path = '/' + this.$mp.page.routeconsole.log(TAG, 'onShareAppMessage path:', path)let title = "进入"let finalParam = {title: title,path: path}if ('button' == options.from && 'video' == options.channel) {}console.log(TAG, 'onShareAppMessage finalParam:', finalParam)return finalParam},methods: {}
}

然后在 main.js app入口文件中混入这个js 方法
import Share from ‘modules/mod_account/Share’
Vue.mixin(Share)
不了解混入机制的参考 :(https://blog.csdn.net/qq_41809113/article/details/121912330)

需要重写的在对应vue文件的data 同级下重写onShareAppMessage方法即可
onShareAppMessage(options) {
console.log(TAG,“onShareAppMessage 点击options:” , options)
},

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com