Files
tra-app/src/pages/test/testChat.vue
T

39 lines
1001 B
Vue

<template>
<view class="">
<view class="cssss">
<CameraPreview ref="CameraPreviewRef"></CameraPreview>
</view>
<view style="margin-top: 400rpx">
<button class="btn" @click="startPreview">开启摄像头预览</button>
<button class="btn" @click="stopPreview">关闭摄像头预览</button>
<button class="btn" @click="switchCamera">切换摄像头</button>
</view>
</view>
</template>
<script setup>
import CameraPreview from './CameraPreview';
import { onReady } from '@dcloudio/uni-app';
import { ref, getCurrentInstance } from 'vue';
const CameraPreviewRef = ref(null);
const instance = getCurrentInstance();
const componentProxy = instance.ctx;
const startPreview = () => {
CameraPreviewRef.value.startPreview();
};
const stopPreview = () => {
CameraPreviewRef.value.stopPreview();
};
const switchCamera = () => {
CameraPreviewRef.value.switchCamera();
};
onReady(() => {
CameraPreviewRef.value.init(componentProxy);
});
</script>
<style>
</style>