• ADADADADAD

    怎么设置小程序页面使用相机[ 建站问答 ]

    建站问答 时间:2024-12-01 19:17:20

    作者:文/会员上传

    简介:

    设置小程序页面使用相机的案例:在对应的wxml文件中添加以下代码:<cameradevice-position="back"flash="off"binderror="error"style="width:100%;height:300px;"></camera><bu

    以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。

    设置小程序页面使用相机的案例:

    在对应的wxml文件中添加以下代码:

    <cameradevice-position="back"flash="off"binderror="error"style="width:100%;height:300px;"></camera>

    <buttontype="primary"bindtap="takePhoto">拍照</button>

    <view>预览</view>

    <imagemode="widthFix"src="{{src}}"></image>

    在对应的js文件中添加以下代码:

    //pages/headline/headline.js

    Page({

    takePhoto(){

    constctx=wx.createCameraContext()

    ctx.takePhoto({

    quality:'high',

    success:(res)=>{

    this.set.Data({

    src:res.tempImagePath

    })

    }

    })

    },

    error(e){

    console.log(e.detail)

    }

    })

    怎么设置小程序页面使用相机.docx

    将本文的Word文档下载到电脑

    推荐度:

    下载