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

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

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

安裝

npm install html5-qrcode

代碼

<template>
	<view class="container">
		<button class="scan" @click="scanCode">打開相機(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>

測試效果

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

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

相關(guān)文章

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

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

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

最新評論

顺昌县| 合肥市| 鄂温| 博客| 蒙山县| 墨玉县| 乐陵市| 文昌市| 贵州省| 得荣县| 陇西县| 巩留县| 依兰县| 克山县| 泊头市| 温泉县| 隆化县| 广河县| 南岸区| 禹州市| 连平县| 桓台县| 大洼县| 绥阳县| 宁化县| 哈巴河县| 班戈县| 东莞市| 武川县| 中卫市| 上思县| 襄汾县| 阆中市| 汾阳市| 长寿区| 三河市| 江陵县| 景谷| 平邑县| 黄浦区| 岳池县|