如何在uniapp中轻松实现二维码扫描功能 (uni.scanCode指南)
最编程
2024-02-22 07:19:51
...
<template>
<view class="scanCodeBox">
<image class='imgCode' src="../static/code.png" mode="" @click="scanCode"></image>
<view class="desc">
扫一扫
</view>
</view>
</template>
<script>
export default {
methods: {
// 点击扫一扫按钮
scanCode() {
uni.scanCode({
success: (res) => {
console.log('扫码成功', res)
},
fail: (err) => {
console.log('扫码失败', err)
},
complete: () => {
console.log('扫码结束')
}
})
},
}
}
</script>