最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

uniapp在h5頁(yè)面實(shí)現(xiàn)掃碼功能(html5-qrcode)

  發(fā)布時(shí)間:2024-06-11 17:05:18   作者:Yui_NIE   我要評(píng)論
這篇文章主要介紹了uniapp在h5頁(yè)面實(shí)現(xiàn)掃碼功能(html5-qrcode),本文結(jié)合實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下

安裝

npm install html5-qrcode

代碼

<template>
	<view class="container">
		<button class="scan" @click="scanCode">打開(kāi)相機(jī)掃碼</button>
		<view class="reader-box" v-if="isScaning">
			<view class="reader" id="reader"></view>
		</view>
	</view>
</template>
<script>
	import {
		Html5Qrcode
	} from 'html5-qrcode';
	export default {
		data() {
			return {
				html5Qrcode: null,
				isScaning: false,
			}
		},
		methods: {
			startScan() {
				this.isScaning = true;
				Html5Qrcode.getCameras().then(devices => {
					if (devices && devices.length) {
						this.html5Qrcode = new Html5Qrcode('reader');
						this.html5Qrcode.start({
							facingMode: 'environment',
						}, {
							fps: 24,
							qrbox: 280
						}, (decodeText, decodeResult) => {
							console.log(decodeText)
							if (decodeText) {
								this.stopScan();
								this.isScaning = false;
							}
						}, (err) => {
							console.log(err)
						});
					}
				});
			},
			stopScan() {
				this.html5Qrcode.stop();
			},
			scanCode() {
				console.log('helo')
				this.startScan();
			}
		}
	}
</script>
<style scoped>
	.container{
		height:100%;
	}
	.reader-box {
		position: fixed;
		top: 0;
		bottom: 0;
		left: 0;
		right: 0;
		background-color: rgba(0, 0, 0, 0.5);
	}
	.reader {
		width: 540rpx;
		height: 540rpx;
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
	}
</style>

測(cè)試效果

uniapp運(yùn)行到瀏覽器

到此這篇關(guān)于uniapp在h5頁(yè)面實(shí)現(xiàn)掃碼功能(html5-qrcode)的文章就介紹到這了,更多相關(guān)html5 qrcode掃碼內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!

相關(guān)文章

  • 使用 html5-qrcode實(shí)現(xiàn)掃碼功能

    html5-qrcode是輕量級(jí)和跨平臺(tái)的QR碼和條形碼掃碼的JS庫(kù),集成二維碼、條形碼和其他一些類(lèi)型的代碼掃描功能,這篇文章主要介紹了使用 html5-qrcode 掃碼功能,需要的朋友可
    2023-09-13
  • uniapp+Html5端實(shí)現(xiàn)PC端適配

    這篇文章主要介紹了uniapp+Html5端實(shí)現(xiàn)PC端適配,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)
    2020-07-15

最新評(píng)論

任丘市| 舞钢市| 衡山县| 鄂温| 喀什市| 探索| 阿尔山市| 会理县| 库车县| 齐河县| 灵丘县| 江源县| 墨脱县| 板桥市| 牡丹江市| 台中市| 库伦旗| 玉树县| 潍坊市| 商水县| 仁化县| 靖州| 顺昌县| 佛冈县| 黄山市| 城步| 湄潭县| 斗六市| 花莲县| 东莞市| 凉城县| 贵州省| 南木林县| 郸城县| 正定县| 云阳县| 阿拉善盟| 青河县| 富川| 当阳市| 汤原县|