Comments (14)
啥版本的QQ浏览器?我不能保证所有的浏览器都能唤起浏览器分享的组件,所以如果对于不支持的可以在catch里做降级处理!
from nativeshare.
本来是可以的,不知道是不是我引入了sea.js引起的。
from nativeshare.
var browser = mobileBrowserType(); //判断浏览器类型
var nativeShare;
//多模块模式
seajs.use(['https://res.wx.qq.com/open/js/jweixin-1.0.0.js', 'NativeShare.js'], function(a, b) {
if(browser == 'weixin'){
weixinShare(a);
} else {
nativeShare = new NativeShare();
var shareData = {
title: share_title,
desc: share_desc,
// 如果是微信该link的域名必须要在微信后台配置的安全域名之内的。
link: share_link,
icon: share_imgUrl
};
nativeShare.setShareData(shareData);
}
});
function call(command) {
try {
if(browser == 'weixin') {
$.toast('请点击右上角分享内容');
return;
}
nativeShare.call(command)
} catch (err) {
// 如果不支持,你可以在这里做降级处理
alert(err.message);
alert(browser);
if(browser == 'i_safari'){
$.popup(".popup-shareTips");
} else {
var errMsg = '';
switch (command){
case 'weibo':
errMsg = '请手动分享到微博';
break;
case 'wechatFriend':
errMsg = '请手动分享给微信好友';
break;
case 'wechatTimeline':
errMsg = '请手动分享到微信朋友圈';
break;
}
$.toast(errMsg);
}
}
}
function setTitle(title) {
nativeShare.setShareData({
title: title
})
}
from nativeshare.
因为在微信浏览器里只能引入了微信分享的js后,微信的分享调用不起来,所以我用sea.js把两个js分别引入了
from nativeshare.
当你在new NativeShare()的时候,库会检查你当前的环境是不是在微信中,如果是,就会去下载微信分享依赖的js文件。微信中你只需要设置appid.....一系列的配置,文档中有写。其他方法都是一样的。至于目前NativeShare应该是不支持seajs引入的!
from nativeshare.
哦哦~!
我不引入微信的js了,设置了appid,但是报{ "errMsg": "config:invalid appid" },可我明明设置了appid啊
from nativeshare.
var nativeShare = new NativeShare({
appId: '{$wx_params.appid}', // 必填,公众号的唯一标识
timestamp: Number('{$wx_params.timestamp}'), // 必填,生成签名的时间戳
nonceStr: '{$wx_params.noncestr}', // 必填,生成签名的随机串
signature: '{$wx_params.sign}'// 必填,签名
});
nativeShare.setShareData({
title: share_title,
desc: share_desc,
// 如果是微信该link的域名必须要在微信后台配置的安全域名之内的。
link: share_link,
icon: share_imgUrl
});
from nativeshare.
报错是这这样的:
输入参数:
{ "timestamp": "undefined", "jsApiList": [ "onMenuShareTimeline", "onMenuShareAppMessage", "onMenuShareQQ", "onMenuShareWeibo", "onMenuShareQZone" ] }
输出参数:
{ "errMsg": "config:invalid appid" }
from nativeshare.
你可以打断点进去看看,是否这些值真的存在?
from nativeshare.
在NativeShare.js里没有找到appId,timestamp,nonceStr,signature这几个变量
from nativeshare.
找到了,参数少传了
var nativeShare = new NativeShare({wechatConfig: {
appId: '{$wx_params.appid}',
timestamp: Number('{$wx_params.timestamp}'),
nonceStr: '{$wx_params.noncestr}',
signature: '{$wx_params.sign}'
}});
这样传就可以了
from nativeshare.
真的万分抱歉,文档写坑了!真亏你能找到!
from nativeshare.
嗯。我是找了好久才找到的!/(ㄒoㄒ)/~~
from nativeshare.
厉害👍
from nativeshare.
Related Issues (20)
- ios系统下,chrome、safari、QQ内置浏览器都不支持,目前只有UC可以用! HOT 6
- 字节跳动旗下的app如何分享朋友圈 HOT 1
- qq空间,微博的调用地址是http的,希望能改成https的
- 目前只能在UC,QQ浏览器上实现效果,其他浏览器不支持,请问怎么改进。 HOT 4
- 本地测试无效果及vue项目引用无效果 HOT 5
- QQ浏览器分享,怎么修改不了显示文案呢? HOT 2
- 请问这个支持https协议的么?http 貌似不成功呢 HOT 2
- 我在域名为http的状态下无法调起。如何才能在http下调用呢。有没有好的解决方案 HOT 4
- 为什么uc浏览器里面分享到qq微信朋友圈微博不显示自己设置的文案、链接、图片呢 HOT 3
- uc分享正常,其他浏览器icon无效, title、desc位置反了 HOT 2
- 安卓系统华为浏览器及百度浏览器不支持、IOS除了UC一切正常
- 是否支持通过nativeShare.call()调用时支持多个渠道? HOT 6
- ios系统 qq浏览器时而可以触发 时而不能触发 HOT 1
- 手机端 the browser may not support command
- 华为Mate 40 用UC浏览器分享到微信时标题、链接、图标都没法自定义,并且链接无法正常打开 HOT 1
- 没有ts类型打包文件
- 为什么我在详情页分享,点击分享链接却到了首页?可以跳转到指定页面链接吗?还有就是可以携带参数吗 HOT 1
- 安卓机qq浏览器第一次无法唤起 HOT 3
- ios 微信分享 图片一直是icon 不是传进去的图片? HOT 1
- 为什么我在引入包的时候报错userAgent undefined
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nativeshare.