在引用微信登录插件后引用正常,试用正常,但是加入state参数后,state不会跟code返回,返回空。
查看源码后发现是因为redirect_uri参数没有编译,导致后面的参数跟在了redirect_uri的链接后面。
redirect_uri: encodeURIComponent('https://www.xxx.com);
在redirect_uri参数上加上encodeURIComponent函数编译就可以了。
var url = "http://baidu.com";
var obj = new WxLogin({
self_redirect:true,
id:"login_container",
appid: "",
scope: "",
redirect_uri: encodeURIComponent(url),
state: "",
style: "",
href: ""
});