dingtalk-mini-adapter
v0.2.0
Published
Adapter for dingtalk mini jsapi
Downloads
8
Readme
使用说明
快速迁移钉钉小程序迁移到政务钉钉,可以采用如下方式:
全局替换方法的命名空间
将 dd 替换成 my
dd.alert({
title: "亲",
content: "您本月的账单已出",
buttonText: "我知道了",
success: () => {
dd.alert({
title: "用户点击了「我知道了」",
});
},
});
// 替换为
my.alert({
title: "亲",
content: "您本月的账单已出",
buttonText: "我知道了",
success: () => {
my.alert({
title: "用户点击了「我知道了」",
});
},
});
引入兼容适配依赖
npm i dingtalk-mini-adapter
在 app.js 入口文件中引入
import gdt from "gdt-jsapi";
import dd from "dingtalk-jsapi";
import adapter from "dingtalk-mini-adapter";
//第一个参数是钉钉 JSAPI,第二个参数是政务钉钉的 JSAPI, 第三个参数是返回是否使用callback方式,默认是promise
adapter(dd, gdt, true);
使用方法
// 在政务钉钉小程序和钉钉小程序下调用H5的API
my.device.notification.alert({
message: "hello",
});
// 在政务钉钉小程序和钉钉小程序调用小程序的API
my.chooseImage({
success(rest) {
console.log(rest);
},
});