国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

【javascript】二維碼

這篇具有很好參考價值的文章主要介紹了【javascript】二維碼。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

javascript二維碼的生成可以用第三方庫qrcode.js。

下載地址:https://gitcode.net/mirrors/davidshimjs/qrcodejs

【javascript】二維碼,# javascript,javascript

解壓后打開index.html文件輸入百度地址回車,就可以看到指定頁面的二維碼了。

?

?html代碼:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
<head>
<title>Cross-Browser QRCode generator for Javascript</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="qrcode.js"></script>
</head>
<body>
<input id="text" type="text" value="http://jindo.dev.naver.com/collie" style="width:80%" /><br />
<div id="qrcode" style="width:100px; height:100px; margin-top:15px;"></div>

<script type="text/javascript">
var qrcode = new QRCode(document.getElementById("qrcode"), {
	width : 100,
	height : 100
});

function makeCode () {		
	var elText = document.getElementById("text");
	
	if (!elText.value) {
		alert("Input a text");
		elText.focus();
		return;
	}
	
	qrcode.makeCode(elText.value);
}

makeCode();

$("#text").
	on("blur", function () {
		makeCode();
	}).
	on("keydown", function (e) {
		if (e.keyCode == 13) {
			makeCode();
		}
	});
</script>
</body>

根據(jù)使用文檔,二維碼的生成需要QRCode對象。?

var qrcode = new QRCode(document.getElementById("qrcode"), {
	text: "http://jindo.dev.naver.com/collie",
	width: 128,
	height: 128,
	colorDark : "blue",
	colorLight : "red",
	correctLevel : QRCode.CorrectLevel.H
});

QRCode有兩個參數(shù),前一個是插入二維碼DOM,后一個可以設(shè)置二維碼的屬性。

text//網(wǎng)址
width//寬度
height//高度
colorDark//點(diǎn)顏色
colorLight//背景顏色
correctLevel//容錯率
    //correctLevel : QRErrorCorrectLevel.L,(7%)
    //correctLevel : QRErrorCorrectLevel.M,(15%)
    //correctLevel : QRErrorCorrectLevel.Q,(25%)
    //correctLevel : QRErrorCorrectLevel.H,(30%)
colorDark : "blue",
colorDark : "blue",
colorLight : "red",

?QRCode有兩個方法:文章來源地址http://www.zghlxwxcb.cn/news/detail-520980.html

qrcode.clear(); // 清除二維碼
qrcode.makeCode("http://naver.com"); // 生成其它二維碼

到了這里,關(guān)于【javascript】二維碼的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包