新建一个uniapp项目,随便放个按钮触发扫码就行
<template>
<view class="content">
<image class="logo" src="/static/logo.png" @tap="scanExam"></image>
<view class="text-area">
<text class="title">{{title}}</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello'
}
},
onLoad() {
},
methods: {
scanExam() {
uni.scanCode({
onlyFromCamera: true,
scanType: ["qrCode", "barCode"],
success: (res) => {
console.log(res)
},
fail: (err) => {
console.log(err);
},
complete: () => {
}
});
}
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>
1 个回复
梦见李阿木 (作者)
更新后确实好了,看来果然是本身的问题,虽然2.8.11也有自己的毛病就是了(捂脸