1. 程式人生 > >接入釘釘企業免登陸遇到的坑!!!!

接入釘釘企業免登陸遇到的坑!!!!

簡單 this str .config .... child onf 代碼 his

今天接入免登陸遇到個大坑,看官方文檔上寫了,先引入dingtalk.js,

然後配置dd.config({...})

接著dd.ready(function(){

..........

});


問題出現了,dd.ready 怎麽也不運行,折騰了一下午,就差跪下來求他了,最後一個不經意的刪除dd.config({}),奇跡出現了,

dd.ready 執行了!!!!蒼天估計被我這種不屈不撓的精神所感動,故意暗中幫了我一把,這才得以將問題解決。

這是下面代碼:

dd.error(function(error){  
                        alert(JSON.stringify(error)) ; 
                    });  
                    dd.ready(
function() { dd.runtime.permission.requestAuthCode({ corpId: _config.corpid, onSuccess: function(result) { LoginByDDCode(result.code).then(res=>{ //這是自己封裝的後臺API
if(!res.error){ this.userinfo=res; this.routerhome(); }else{ this.openid=res.openid; } }); }, onFail :
function(err) { alert(‘requestAuthCode fail: ‘ + JSON.stringify(err)); } }); })

哦,對了,還有個問題要註意,就是在vue中引用外部的js.有時會失效。有個最簡單的辦法就是:

mounted(){
    let s = document.createElement(‘script‘);
            s.type = ‘text/javascript‘;
            s.src = ‘http://g.alicdn.com/dingding/open-develop/1.5.1/dingtalk.js‘; 
            document.body.appendChild(s);
}

接入釘釘企業免登陸遇到的坑!!!!