npm引入的dingtalk-jsapi会报错 ,_typeof is not function;
这个问题找了两天,无法解决,包括找了几个专业前端帮忙看了下也是没找到解决办法,只能换了另一种引入方式
1、在 index.html 中 script 引入dingtalk-jsapi
<script src="https://g.alicdn.com/dingding/dingtalk-jsapi/2.10.3/dingtalk.open.js"></script>
2、在登录页面直接 window.dd 调用
let that = this
window.dd.ready(function() {
// dd.ready参数为回调函数,在环境准备就绪时触发,jsapi的调用需要保证在该回调函数触发后调用,否则无效。
window.dd.runtime.permission.requestAuthCode({
corpId: "xxx",
onSuccess: function(result) {
that.handleLogin({code:result.code})
},
onFail: function(err) {
alert('err:')
alert(err)
}
});
});
可以完美解决,注意:success 回调中不能用 this !!!