uni-app扫描二维码封装

uni-app扫描二维码封装

不墨迹直接上代码

此处如果打包的时候还要把摄像头权限开启
操作步骤

测试的话直接就下面代码测试就ok了

<template>
	<view>
		<button type="primary" @click="tel()">button</button>
	</view>
</template>
<script>
	export default {
    
    
		data() {
    
    
			return {
    
    
			};
		},		
		methods:{
    
    
			tel:function(){
    
    
				console.log(111)
				uni.scanCode({
    
    
					success:function(res){
    
    
						console.log(JSON.stringify(res)); //扫描成功返回的数据
					}
				});
			}
		}
	}
</script>
 
<style>
 
</style>

猜你喜欢

转载自blog.csdn.net/weixin_48255917/article/details/110545210