钉钉多端统一jsapi
此 jsApi 支持运行于 android, ios, pc,钉钉小程序,小程序内嵌 webview 等钉钉全环境下,且保持开发体验一致。
安装
dingtalk-jsapi 现在可从 npm
上安装.
npm install dingtalk-jsapi
推荐使用npm包形式按需引入
新的特性
除了兼容现钉钉开放平台提供的jsapi的特性,还支持以下下特性
- 支持返回原生 Promise
- 支持模块化引入 api,模块化引入平台
- 支持 dd.checkJsApi, 用于检测当前环境是否支持此jsApi
- 提供 dd.on, dd.off来绑定事件,用于同一绑定事件
- 添加 dd.env 来读取当前环境变量
- 支持 typescript 的接口定义,接口定义还在持续添加中,如有纰漏欢迎反馈
使用介绍
整体调用
import * as dd from 'dingtalk-jsapi';
dd.device.notification.alert({
message: "亲爱的",
title: "提示",
buttonName: "收到",
}).then(() => {
}, () => {
});
按需调用(占用体积小)
import 'dingtalk-jsapi/entry/mobile';
import alert from 'dingtalk-jsapi/api/device/notification/alert';
alert({
message: "亲爱的",
title: "提示",
buttonName: "收到",
}).then(() => {
}, () => {
});
dd.ready优化
旧版本pc调用接口
dd.config({
agentId: '',
corpId: '',
timeStamp: ,
nonceStr: '',
signature: '',
type:0/1,
jsApiList:[
'biz.contact.choose',
],
});
dd.ready(() => {
dd.device.notification.alert({
message: "亲爱的",
title: "提示",
buttonName: "收到",
}).then(() => {
}, () => {
});
})
新版本pc调用接口
dd.config({
agentId: '',
corpId: '',
timeStamp: ,
nonceStr: '',
signature: '',
type:0/1,
jsApiList:[
'device.notification.alert',
],
});
dd.device.notification.alert({
message: "亲爱的",
title: "提示",
buttonName: "收到",
}).then(() => {
}, () => {
});
反馈渠道
亲爱的开发者,为了更好的提高服务效率和问题沉淀,在开发过程中如果遇到问题,可以有以下方式获取技术支持:
【推荐】登录开发者后台,https://open-dev.dingtalk.com,在右下角有“在线帮助”(人工客服时间:工作日10:00~12:00,14:00~18:00, 19:00~21:00)
最终解释权归阿里巴巴钉钉事业部所有。