Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

有两个小问题,引入qrcode.min.js文件+配置项container的'id'模式 #6

Open
coohuo opened this issue Sep 24, 2017 · 2 comments

Comments

@coohuo
Copy link

coohuo commented Sep 24, 2017

引入qrcode.min.js文件,需要在引用页面的同级目录下。不然,二维码无法出现
如,某站首页****/index.html、子页面****/XXX/index.html的同级目录,分别有qrcode.min.js
试了对loadjs函数这样调整后,可以自动加载在iShare.js|iShare_tidy.js同级目录的qrcode.min.js文件
iShare_tidy.js 409行
W3C = document.dispatchEvent, js = document.scripts, path = js[js.length - 1].src; path = path.substring(0, path.lastIndexOf('/')+1); cb.push(callback); if(!ready){ node.setAttribute('type', 'text/javascript'); node.setAttribute('id', 'loaded'); node.setAttribute('src', path+url);
iShare_tidy.min.js
j=document.dispatchEvent后增加
,s=document.scripts,p=s[s.length-1].src;p=p.substring(0,p.lastIndexOf('/')+1)
k.setAttribute("src",h)调整为
k.setAttribute("src",p+h)

配置项container的'id'模式无效,代码_node = document.getElementById(selector); 尝试进行如下调整,去掉#,id模式正常
_node = document.getElementById(selector.slice(1));
min压缩版,f=document.getElementById(e)改成了f=document.getElementById(e.slice(1)),正常

@zhansingsong 请查看

@bibichuan
Copy link
Collaborator

bibichuan commented Jun 12, 2019

qrcode.min.js放到iShare.js同级目录下,并不能自动找到,qrcode.min.js的路径中会加上页面的url。手动引入的qrcode.min似乎不起作用。 @zhansingsong 还更新吗,这个插件

@bibichuan
Copy link
Collaborator

bibichuan commented Jun 12, 2019

我觉得你说 @coohuo的也不对,p=s[s.length-1].src;,并不一定是当前iShare的路径。我觉得最好判断一下。
var js = document.scripts; var path = ""; var c=js.length; for(var i=0;i<c;i++){ var it=js[i]; var src=it.src; if(src.indexOf("iShare")>=0){ path=src.substring(0,src.lastIndexOf('/')+1) } } Util.loadjs(path+'qrcode.min.js', this.wx.startQR());
当然这里的indexOf('iShare')也不能保证加载的就是iShare.js,如果用户改名了,这个文件不叫iShare.js了,那就不好办了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants