需求:
要实现在微信中分享给朋友和分享到朋友圈的分享链接显示图片,标题和描述.
实现:
遇到的问题:
写好的index.html发布到服务器上,发现显示的还是链接,加的微信分享功能没有起作用------这段代码没有读取到.于是我f12查看前端有没有报错.
发现index.html页面报了一个wx not defined错误.在网上查了一下.http://blog.csdn.net/xinyflove/article/details/52461210
原文内容:
微信分享 “Reference error wx is not defined”错误很有可能是jweixin-1.0.0.js与你其它某js冲突。
解决办法:
<script type="text/javascript">
define = null;
require = null;
</script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript">
</script>
- 1
- 2
- 3
- 4
- 5
- 6
在引用jweixin-1.0.0.js之前,重置define、require即可。
方法二、
可以把
引入微信js提前,尽可能提前,这样也可以解决这样的问题。