m-share
Version:
h5页面分享组件、支持分享到微信、朋友圈、qq、QQ空间、QQ好友。
34 lines (33 loc) • 1.35 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>js调用分享</title>
<style>
</style>
<script src="../dist/m-share.js"></script>
</head>
<body>
<button style="background: #7bc549;color: #fff;" id="wx">分享到微信</button>
<button style="background: #fdbe3d;color: #fff;" id="qzone">分享到QQ空间</button>
<script>
var config = {
title: 'm-share', // 标题,默认读取document.title
desc: 'm-share的描述', // 描述, 默认读取head标签:<meta name="description" content="desc" />
link: 'http://www.dearhaoge.com/project/m-share/', // 网址,默认使用window.location.href
imgUrl: 'http://www.dearhaoge.com/project/m-share/shareIcon.jpg', // 图片, 默认取网页中第一个img标签
fnDoShare: function (type) {
console.log(1);
}
};
document.querySelector('#wx').addEventListener('click', function () {
Mshare.to('wx', config);
});
document.querySelector('#qzone').addEventListener('click', function () {
Mshare.to('qzone', config);
});
</script>
</body>
</html>