vue的h5项目在钉钉中分享的样式
2021-09-09 本文已影响0人
IssunRadiance
1.在index.html中引入js文件
<script type="text/javascript" src="https://g.alicdn.com/dingding/open-develop/1.9.0/dingtalk.js"></script>
2.创建一个js文件ddapi.js
export default {
ddShowMenu: function(title, img) {
dd.ready(function() {
dd.biz.navigation.setRight({
show: true,
control: true,
text: '...', //空字符串表示显示默认文本
onSuccess: function(result) {
dd.biz.util.share({
type: 0, //分享类型,0:全部组件 默认; 1:只能分享到钉钉;2:不能分享,只有刷新按钮
url: '分享的地址',
content: '分享的描述',
title: '分享的名字!',
image: '图片地址',
onSuccess: function() {},
onFail: function(err) {}
})
},
onFail: function(err) {}
});
})
}
}
3.在main.js中引入
import DDConfig from './assets/js/ddapi' // 钉钉分享 ddapi.js的路径
Vue.prototype.DDConfig = DDConfig;
4.在要分享的页面中调用
mounted() {
this.DDConfig.ddShowMenu();
},