学无先后,达者为师

网站首页 编程语言 正文

uniapp 调用拍照组件

作者:maoge_666 更新时间: 2023-07-16 编程语言

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

代码示例:

<template>
	<view>
        <camera device-position="back" flash="off" @error="error" style="width: 100%; height: 300px;"></camera>
        <button type="primary" @click="takePhoto">拍照</button>
        <view>预览</view>
        <image mode="widthFix" :src="src"></image>
    </view>
</template>

export default {
    data() {
        return {
            src:""
        }
    },
    methods: {
         takePhoto() {
            const ctx = uni.createCameraContext();
            ctx.takePhoto({
                quality: 'high',
                success: (res) => {
                    this.src = res.tempImagePath
                }
            });
        },
        error(e) {
            console.log(e.detail);
        }
    }
}


原文链接:https://blog.csdn.net/maoge_666/article/details/131081194

  • 上一篇:没有了
  • 下一篇:没有了
栏目分类
最近更新