使用uniapp实现扫码功能
<template>
<view>
<view class="action text-gray add-action" @tap="scan">
<button class="cu-btn cuIcon-scan bg-green shadow"></button>
扫一扫
</view>
</view>
</template>
<script>
export default {
methods: {
// 扫码
scan(){
console.log("进来了")
// #ifndef H5
uni.scanCode({
success: function (res) {
console.log('条码res:' + res);
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
}
});
// #endif
// #ifdef H5
this.$tip.alert("暂不支持")
// #endif
},
}
}
</script>