123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <template>
- <view>
- <page-head :title="title"></page-head>
- <view class="uni-padding-wrap uni-common-mt">
- <view class="uni-title">扫码结果:</view>
- <view v-if="result" class="scan-result">
- {{result}}
- </view>
- <view class="uni-btn-v">
- <button type="primary" @click="scan">扫一扫</button>
- </view>
- </view>
- </view>
- </template>
- <script lang="uts">
- export default {
- data() {
- return {
- title: 'scanCode',
- result: ''
- }
- },
- methods: {
- scan() {
- uni.scanCode({
- success: (res: ScanCodeSuccess) => {
- console.log('res: ',res);
- this.result = res.result
- },
- fail: (err: ScanCodeFail) => {
- console.log('err: ',err);
- // 需要注意的是小程序扫码不需要申请相机权限
- }
- });
- }
- }
- }
- </script>
- <style>
- .scan-result {
- min-height: 25px;
- line-height: 25px;
- }
- </style>
|