41 lines
933 B
Plaintext
41 lines
933 B
Plaintext
<template>
|
||
<view>
|
||
<image class="logo" src="/static/logo.png"></image>
|
||
<text class="title">{{title}}</text>
|
||
<xf-camera style="height:750rpx; background-color: red;" @error="onError" :flash="flash"
|
||
:position="device"></xf-camera>
|
||
<image v-if="imagePath" mode="aspectFit" :src="imagePath"></image>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup lang="uts">
|
||
const title = ref('Hello')
|
||
// 相机闪光灯状态('off' | 'on' | 'auto')
|
||
const flash = ref('off')
|
||
|
||
// 相机朝向('front' | 'back')
|
||
const device = ref('back')
|
||
|
||
// 拍摄的图片路径
|
||
const imagePath = ref('')
|
||
|
||
// 相机错误处理
|
||
const onError = (e : any) => {
|
||
console.log('相机错误:', e)
|
||
// 可在此添加用户提示,如 uni.showToast
|
||
}
|
||
</script>
|
||
|
||
<style>
|
||
.logo {
|
||
height: 100px;
|
||
width: 100px;
|
||
margin: 100px auto 25px auto;
|
||
}
|
||
|
||
.title {
|
||
font-size: 18px;
|
||
color: #8f8f94;
|
||
text-align: center;
|
||
}
|
||
</style> |