File tree 1 file changed +5
-1
lines changed
1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change 13
13
window . onload = function ( ) {
14
14
var oQrCode = document . getElementById ( 'qrcode' ) ;
15
15
var oT = document . getElementById ( 't1' ) ;
16
+ var oT2 = document . getElementById ( 't2' ) ;
16
17
var oBtn = document . getElementById ( 'btn1' ) ;
18
+ var oSpan = document . querySelector ( '#qrcode .img' ) ;
17
19
18
20
var qrCode = new QRCode ( oQrCode , { width :200 , height :200 } ) ;
19
21
20
22
qrCode . makeCode ( 'http://www.itstrive.com' ) ; //默认随便给一个
21
23
22
24
oBtn . onclick = function ( ) {
25
+ oSpan . style . backgroundImage = 'url(' + oT2 . value + ')' ;
23
26
qrCode . makeCode ( oT . value ) ;
24
27
} ;
25
28
} ;
30
33
< div id ="qrcode ">
31
34
< span class ="img "> </ span >
32
35
</ div >
33
- < input type ="text " id ="t1 ">
36
+ 二维码地址:< input type ="text " placeholder ="http://www.baidu.com " id ="t1 ">
37
+ 中心图像地址:< input type ="url " placeholder ="https://www.baidu.com/img/bd_logo1.png " id ="t2 ">
34
38
< input type ="button " value ="生成二维码 " id ="btn1 ">
35
39
</ body >
36
40
</ html >
You can’t perform that action at this time.
0 commit comments